Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inox
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
6
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
a2d70967
Commit
a2d70967
authored
8 years ago
by
Nicolas Voirol
Browse files
Options
Downloads
Patches
Plain Diff
Small API changes in Paths
parent
d873a479
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/scala/inox/ast/Paths.scala
+13
-4
13 additions, 4 deletions
src/main/scala/inox/ast/Paths.scala
with
13 additions
and
4 deletions
src/main/scala/inox/ast/Paths.scala
+
13
−
4
View file @
a2d70967
...
...
@@ -29,9 +29,7 @@ trait Paths { self: SymbolOps with TypeOps =>
* not defined, whereas an encoding of let-bindings with equalities
* could introduce non-sensical equations.
*/
class
Path
private
(
private
[
ast
]
val
elements
:
Seq
[
Path.Element
])
extends
Printable
{
class
Path
private
(
private
[
ast
]
val
elements
:
Seq
[
Path.Element
])
extends
Printable
{
import
Path.Element
/** Add a binding to this [[Path]] */
...
...
@@ -71,6 +69,17 @@ trait Paths { self: SymbolOps with TypeOps =>
*/
def
map
(
f
:
Expr
=>
Expr
)
=
new
Path
(
elements
.
map
(
_
.
left
.
map
{
case
(
vd
,
e
)
=>
vd
->
f
(
e
)
}.
right
.
map
(
f
)))
/** Transforms both let bindings and expressions inside the path
*
* The function [[fVal]] is applied to all values in [[bound]] and [[fExpr]] is applied
* to both the bodies of the [[bindings]] as well as the [[conditions]].
*
* @see [[map(Expr => Expr)]] for a map only defined on expressions
*/
def
map
(
fVal
:
ValDef
=>
ValDef
,
fExpr
:
Expr
=>
Expr
)
=
new
Path
(
elements
.
map
(
_
.
left
.
map
{
case
(
vd
,
e
)
=>
fVal
(
vd
)
->
fExpr
(
e
)
}.
right
.
map
(
fExpr
))
)
/** Instantiates type parameters within the path
*
* Type parameters within a path may appear both inside expressions and in
...
...
@@ -149,7 +158,7 @@ trait Paths { self: SymbolOps with TypeOps =>
)(
elements
)
lazy
val
bindings
:
Seq
[(
ValDef
,
Expr
)]
=
elements
.
collect
{
case
Left
(
p
)
=>
p
}
lazy
val
bound
Ids
=
bindings
map
(
_
.
_1
)
lazy
val
bound
=
bindings
map
(
_
.
_1
)
lazy
val
conditions
:
Seq
[
Expr
]
=
elements
.
collect
{
case
Right
(
e
)
=>
e
}
def
isBound
(
id
:
Identifier
)
:
Boolean
=
bindings
.
exists
(
p
=>
p
.
_1
.
id
==
id
)
...
...
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