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
f6451aaa
Commit
f6451aaa
authored
12 years ago
by
Régis Blanc
Browse files
Options
Downloads
Patches
Plain Diff
move hoistIte in Trees
parent
f79c3607
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
+0
-28
0 additions, 28 deletions
src/main/scala/leon/CallGraph.scala
src/main/scala/leon/purescala/Trees.scala
+30
-0
30 additions, 0 deletions
src/main/scala/leon/purescala/Trees.scala
with
30 additions
and
28 deletions
src/main/scala/leon/CallGraph.scala
+
0
−
28
View file @
f6451aaa
...
...
@@ -139,34 +139,6 @@ class CallGraph(val program: Program) {
rebuildPath
(
to
,
List
())
}
//guarentee that all IfExpr will be at the top level and as soon as you encounter a non-IfExpr, then no more IfExpr can be find in the sub-expressions
def
hoistIte
(
expr
:
Expr
)
:
Expr
=
{
def
transform
(
expr
:
Expr
)
:
Option
[
Expr
]
=
expr
match
{
case
uop
@UnaryOperator
(
IfExpr
(
c
,
t
,
e
),
op
)
=>
Some
(
IfExpr
(
c
,
op
(
t
).
setType
(
uop
.
getType
),
op
(
e
).
setType
(
uop
.
getType
)).
setType
(
uop
.
getType
))
case
bop
@BinaryOperator
(
IfExpr
(
c
,
t
,
e
),
t2
,
op
)
=>
Some
(
IfExpr
(
c
,
op
(
t
,
t2
).
setType
(
bop
.
getType
),
op
(
e
,
t2
).
setType
(
bop
.
getType
)).
setType
(
bop
.
getType
))
case
bop
@BinaryOperator
(
t1
,
IfExpr
(
c
,
t
,
e
),
op
)
=>
Some
(
IfExpr
(
c
,
op
(
t1
,
t
).
setType
(
bop
.
getType
),
op
(
t1
,
e
).
setType
(
bop
.
getType
)).
setType
(
bop
.
getType
))
case
nop
@NAryOperator
(
ts
,
op
)
=>
{
val
iteIndex
=
ts
.
indexWhere
{
case
IfExpr
(
_
,
_
,
_
)
=>
true
case
_
=>
false
}
if
(
iteIndex
==
-
1
)
None
else
{
val
(
beforeIte
,
startIte
)
=
ts
.
splitAt
(
iteIndex
)
val
afterIte
=
startIte
.
tail
val
IfExpr
(
c
,
t
,
e
)
=
startIte
.
head
Some
(
IfExpr
(
c
,
op
(
beforeIte
++
Seq
(
t
)
++
afterIte
).
setType
(
nop
.
getType
),
op
(
beforeIte
++
Seq
(
e
)
++
afterIte
).
setType
(
nop
.
getType
)
).
setType
(
nop
.
getType
))
}
}
case
_
=>
None
}
def
fix
[
A
](
f
:
(
A
)
=>
A
,
a
:
A
)
:
A
=
{
val
na
=
f
(
a
)
if
(
a
==
na
)
a
else
fix
(
f
,
na
)
}
fix
(
searchAndReplaceDFS
(
transform
),
expr
)
}
lazy
val
toDotString
:
String
=
{
var
vertexLabels
:
Set
[(
String
,
String
)]
=
Set
()
...
...
This diff is collapsed.
Click to expand it.
src/main/scala/leon/purescala/Trees.scala
+
30
−
0
View file @
f6451aaa
...
...
@@ -1466,4 +1466,34 @@ object Trees {
case
FunctionType
(
fromTypes
,
toType
)
=>
AnonymousFunction
(
Seq
.
empty
,
simplestValue
(
toType
)).
setType
(
tpe
)
case
_
=>
throw
new
Exception
(
"I can't choose simplest value for type "
+
tpe
)
}
//guarentee that all IfExpr will be at the top level and as soon as you encounter a non-IfExpr, then no more IfExpr can be find in the sub-expressions
//require no-match, no-ets and only pure code
def
hoistIte
(
expr
:
Expr
)
:
Expr
=
{
def
transform
(
expr
:
Expr
)
:
Option
[
Expr
]
=
expr
match
{
case
uop
@UnaryOperator
(
IfExpr
(
c
,
t
,
e
),
op
)
=>
Some
(
IfExpr
(
c
,
op
(
t
).
setType
(
uop
.
getType
),
op
(
e
).
setType
(
uop
.
getType
)).
setType
(
uop
.
getType
))
case
bop
@BinaryOperator
(
IfExpr
(
c
,
t
,
e
),
t2
,
op
)
=>
Some
(
IfExpr
(
c
,
op
(
t
,
t2
).
setType
(
bop
.
getType
),
op
(
e
,
t2
).
setType
(
bop
.
getType
)).
setType
(
bop
.
getType
))
case
bop
@BinaryOperator
(
t1
,
IfExpr
(
c
,
t
,
e
),
op
)
=>
Some
(
IfExpr
(
c
,
op
(
t1
,
t
).
setType
(
bop
.
getType
),
op
(
t1
,
e
).
setType
(
bop
.
getType
)).
setType
(
bop
.
getType
))
case
nop
@NAryOperator
(
ts
,
op
)
=>
{
val
iteIndex
=
ts
.
indexWhere
{
case
IfExpr
(
_
,
_
,
_
)
=>
true
case
_
=>
false
}
if
(
iteIndex
==
-
1
)
None
else
{
val
(
beforeIte
,
startIte
)
=
ts
.
splitAt
(
iteIndex
)
val
afterIte
=
startIte
.
tail
val
IfExpr
(
c
,
t
,
e
)
=
startIte
.
head
Some
(
IfExpr
(
c
,
op
(
beforeIte
++
Seq
(
t
)
++
afterIte
).
setType
(
nop
.
getType
),
op
(
beforeIte
++
Seq
(
e
)
++
afterIte
).
setType
(
nop
.
getType
)
).
setType
(
nop
.
getType
))
}
}
case
_
=>
None
}
def
fix
[
A
](
f
:
(
A
)
=>
A
,
a
:
A
)
:
A
=
{
val
na
=
f
(
a
)
if
(
a
==
na
)
a
else
fix
(
f
,
na
)
}
fix
(
searchAndReplaceDFS
(
transform
),
expr
)
}
}
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