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
b62680b0
Commit
b62680b0
authored
9 years ago
by
Manos Koukoutos
Browse files
Options
Downloads
Patches
Plain Diff
Make couple of things more readable
parent
9e0320a4
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/purescala/TypeOps.scala
+10
-26
10 additions, 26 deletions
src/main/scala/leon/purescala/TypeOps.scala
with
10 additions
and
26 deletions
src/main/scala/leon/purescala/TypeOps.scala
+
10
−
26
View file @
b62680b0
...
...
@@ -9,24 +9,20 @@ import Common._
import
Expressions._
import
Extractors._
import
Constructors._
import
ExprOps.preMap
object
TypeOps
extends
{
val
Deconstructor
=
NAryType
}
with
SubTreeOps
[
TypeTree
]
{
def
typeDepth
(
t
:
TypeTree
)
:
Int
=
t
match
{
case
NAryType
(
tps
,
builder
)
=>
1
+
(
0
+:
(
tps
map
typeDepth
)).
max
}
def
typeParamsOf
(
t
:
TypeTree
)
:
Set
[
TypeParameter
]
=
{
collect
[
TypeParameter
]({
case
tp
:
TypeParameter
=>
Set
(
tp
)
case
_
=>
Set
.
empty
})(
t
)
def
typeParamsOf
(
expr
:
Expr
)
:
Set
[
TypeParameter
]
=
{
ExprOps
.
collect
(
e
=>
typeParamsOf
(
e
.
getType
))(
expr
)
}
def
typeParamsOf
(
expr
:
Expr
)
:
Set
[
TypeParameter
]
=
{
var
tparams
:
Set
[
TypeParameter
]
=
Set
.
empty
ExprOps
.
preTraversal
(
e
=>
typeParamsOf
(
e
.
getType
))(
expr
)
tparams
def
typeParamsOf
(
t
:
TypeTree
)
:
Set
[
TypeParameter
]
=
t
match
{
case
tp
:
TypeParameter
=
>
Set
(
tp
)
case
NAryType
(
subs
,
_
)
=>
subs
.
flatMap
(
typeParamsOf
).
toSet
}
def
canBeSubtypeOf
(
...
...
@@ -345,7 +341,7 @@ object TypeOps extends { val Deconstructor = NAryType } with SubTreeOps[TypeTree
Let
(
newId
,
srec
(
value
),
rec
(
idsMap
+
(
id
->
newId
))(
body
)).
copiedFrom
(
l
)
case
l
@
LetDef
(
fds
,
bd
)
=>
val
fds
_m
apping
=
for
(
fd
<-
fds
)
yield
{
val
fds
M
apping
=
for
(
fd
<-
fds
)
yield
{
val
id
=
fd
.
id
.
freshen
val
tparams
=
fd
.
tparams
map
{
p
=>
TypeParameterDef
(
tpeSub
(
p
.
tp
).
asInstanceOf
[
TypeParameter
])
...
...
@@ -362,13 +358,10 @@ object TypeOps extends { val Deconstructor = NAryType } with SubTreeOps[TypeTree
(
fd
,
newFd
,
subCalls
)
}
// We group the subcalls functions all in once
val
subCalls
=
(((
None
:
Option
[
Expr
=>
Expr
])
/:
fds_mapping
)
{
case
(
None
,
(
_
,
_
,
subCalls
))
=>
Some
(
subCalls
)
case
(
Some
(
fn
),
(
_
,
_
,
subCalls
))
=>
Some
(
fn
andThen
subCalls
)
}).
get
val
subCalls
=
fdsMapping
.
map
(
_
.
_3
).
reduceLeft
{
_
andThen
_
}
// We apply all the functions mappings at once
val
newFds
=
for
((
fd
,
newFd
,
_
)
<-
fds
_m
apping
)
yield
{
val
newFds
=
for
((
fd
,
newFd
,
_
)
<-
fds
M
apping
)
yield
{
val
fullBody
=
rec
(
idsMap
++
fd
.
paramIds
.
zip
(
newFd
.
paramIds
))(
subCalls
(
fd
.
fullBody
))
newFd
.
fullBody
=
fullBody
newFd
...
...
@@ -436,16 +429,7 @@ object TypeOps extends { val Deconstructor = NAryType } with SubTreeOps[TypeTree
}
}
//println("\\\\"*80)
//println(tps)
//println(ids.map{ case (k,v) => k.uniqueName+" -> "+v.uniqueName })
//println("\\\\"*80)
//println(e)
val
res
=
rec
(
ids
)(
e
)
//println(".."*80)
//println(res)
//println("//"*80)
res
rec
(
ids
)(
e
)
}
}
}
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