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
e4b04d27
Commit
e4b04d27
authored
13 years ago
by
Régis Blanc
Browse files
Options
Downloads
Patches
Plain Diff
hoisting ite function
parent
7fbb9a55
No related branches found
No related tags found
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/scala/leon/CallGraph.scala
+80
-22
80 additions, 22 deletions
src/main/scala/leon/CallGraph.scala
with
80 additions
and
22 deletions
src/main/scala/leon/CallGraph.scala
+
80
−
22
View file @
e4b04d27
...
@@ -26,34 +26,74 @@ class CallGraph(val program: Program) {
...
@@ -26,34 +26,74 @@ class CallGraph(val program: Program) {
null
null
}
}
// def hoistIte(expr: Expr): Expr = expr match {
def
hoistIte
(
expr
:
Expr
)
:
Expr
=
{
// case ite@IfExpr(c, t, e) => IfExpr(c, hoistIte(t), hoistIte(e)).setType(ite.getType)
// case BinaryOperator(t1, t2) =>
//
// }
//def analyse(program: Program) {
def
transform
(
expr
:
Expr
)
:
Expr
=
expr
match
{
// z3Solver.setProgram(program)
case
ite
@IfExpr
(
c
,
t
,
e
)
=>
ite
// reporter.info("Running test generation")
case
BinaryOperator
(
IfExpr
(
c
,
t
,
e
),
t2
,
op
)
=>
IfExpr
(
c
,
op
(
t
,
t2
),
op
(
e
,
t2
))
// val allFuns = program.definedFunctions
case
BinaryOperator
(
t1
,
IfExpr
(
c
,
t
,
e
),
op
)
=>
IfExpr
(
c
,
op
(
t1
,
t
),
op
(
t1
,
e
))
// allFuns.foreach(fd => {
case
(
t
:
Terminal
)
=>
t
// val testcases = generateTestCases(fd)
}
// reporter.info("Running " + fd.id + " with the following testcases:\n")
// reporter.info(testcases.mkString("\n"))
// })
//}
//private def generatePathConditions(funDef: FunDef): Seq[Expr] = if(!funDef.hasImplementation) Seq() else {
def
fix
[
A
](
f
:
(
A
)
=>
A
,
a
:
A
)
:
A
=
{
// val body = funDef.body.get
val
na
=
f
(
a
)
// val cleanBody = expandLets(matchToIfThenElse(body))
if
(
a
==
na
)
a
else
fix
(
f
,
na
)
// collectWithPathCondition(cleanBody)
}
fix
(
transform
,
expr
)
}
//def hoistIte(expr: Expr): (Seq[Expr] => Expr, Seq[Expr]) = expr match {
// case ite@IfExpr(c, t, e) => {
// val (iteThen, valsThen) = hoistIte(t)
// val nbValsThen = valsThen.size
// val (iteElse, valsElse) = hoistIte(e)
// val nbValsElse = valsElse.size
// def ite(es: Seq[Expr]): Expr = {
// val argsThen = es.take(nbValsThen)
// val argsElse = es.drop(nbValsThen)
// IfExpr(c, iteThen(argsThen), iteElse(argsElse), e2)
// }
// (ite, valsThen ++ valsElse)
// }
// case BinaryOperator(t1, t2, op) => {
// val (iteLeft, valsLeft) = hoistIte(t1)
// val (iteRight, valsRight) = hoistIte(t2)
// def ite(e1: Expr, e2: Expr): Expr = {
// }
// iteLeft(
// iteRight(
// op(thenValRight, thenValLeft),
// op(thenValRight, elseValLeft)
// ), iteRight(
// op(elseValRight, thenValLeft),
// op(elseValRight, elseValLeft)
// )
// )
// }
// case NAryOperator(args, op) => {
// }
// case (t: Terminal) => {
// def ite(es: Seq[Expr]): Expr = {
// require(es.size == 1)
// es.head
// }
// (ite, Seq(t))
// }
// case _ => scala.sys.error("Unhandled tree in hoistIte : " + expr)
//}
//}
//
//
prec: there should be no lets and no pattern-matching in this expression
// prec: there should be no lets and no pattern-matching in this expression
//
private def collectWithPathCondition(expression: Expr): Seq[Expr] = {
//private def collectWithPathCondition(expression: Expr
, cond: Seq[Expr]
): Seq[Expr] = {
// var allPaths: Seq[Expr] = Seq()
// var allPaths: Seq[Expr] = Seq()
// def rec(expr: Expr, path: Expr): Seq[Expr] = expr match {
// def rec(expr: Expr, path: Seq[Expr]): Seq[Expr] = {
// expr match {
// case FunctionInvocLabel(fd, args) =>
// case WayPoint(e) =>
// }
//
// case IfExpr(cond, then, elze) =>
// case IfExpr(cond, then, elze) =>
// (if(!containsIfExpr(then)) Seq(And(path, cond)) else rec(then, And(cond, path))) ++
// (if(!containsIfExpr(then)) Seq(And(path, cond)) else rec(then, And(cond, path))) ++
// (if(!containsIfExpr(elze)) Seq(And(path, Not(cond))) else rec(then, And(cond, path)))
// (if(!containsIfExpr(elze)) Seq(And(path, Not(cond))) else rec(then, And(cond, path)))
...
@@ -66,4 +106,22 @@ class CallGraph(val program: Program) {
...
@@ -66,4 +106,22 @@ class CallGraph(val program: Program) {
// rec(expression, BooleanLiteral(true)).distinct
// rec(expression, BooleanLiteral(true)).distinct
//}
//}
//def analyse(program: Program) {
// z3Solver.setProgram(program)
// reporter.info("Running test generation")
// val allFuns = program.definedFunctions
// allFuns.foreach(fd => {
// val testcases = generateTestCases(fd)
// reporter.info("Running " + fd.id + " with the following testcases:\n")
// reporter.info(testcases.mkString("\n"))
// })
//}
//private def generatePathConditions(funDef: FunDef): Seq[Expr] = if(!funDef.hasImplementation) Seq() else {
// val body = funDef.body.get
// val cleanBody = expandLets(matchToIfThenElse(body))
// collectWithPathCondition(cleanBody)
//}
}
}
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