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
ce17562d
Commit
ce17562d
authored
5 years ago
by
Jad Hamza
Browse files
Options
Downloads
Patches
Plain Diff
Add an option to copy positions from old tree when doing substitutions
parent
eb87ecf0
Branches
github/fork/jad-hamza/replaceFromSymbols-positions
No related tags found
1 merge request
!107
Add an option to copy positions from old tree when doing substitutions
Pipeline
#160623
failed
1 year ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/scala/inox/ast/ExprOps.scala
+9
-2
9 additions, 2 deletions
src/main/scala/inox/ast/ExprOps.scala
src/main/scala/inox/ast/Types.scala
+7
-3
7 additions, 3 deletions
src/main/scala/inox/ast/Types.scala
with
16 additions
and
5 deletions
src/main/scala/inox/ast/ExprOps.scala
+
9
−
2
View file @
ce17562d
...
@@ -38,10 +38,17 @@ trait ExprOps extends GenTreeOps {
...
@@ -38,10 +38,17 @@ trait ExprOps extends GenTreeOps {
lazy
val
Deconstructor
=
Operator
lazy
val
Deconstructor
=
Operator
/** Replaces bottom-up variables by looking up for them in a map */
/** Replaces bottom-up variables by looking up for them in a map */
def
replaceFromSymbols
[
V
<:
VariableSymbol
](
substs
:
Map
[
V
,
Expr
],
expr
:
Expr
)(
implicit
ev
:
VariableConverter
[
V
])
:
Expr
=
{
def
replaceFromSymbols
[
V
<:
VariableSymbol
](
substs
:
Map
[
V
,
Expr
],
expr
:
Expr
,
copyPositions
:
Boolean
=
false
)(
implicit
ev
:
VariableConverter
[
V
])
:
Expr
=
{
new
SelfTreeTransformer
{
new
SelfTreeTransformer
{
override
def
transform
(
expr
:
Expr
)
:
Expr
=
expr
match
{
override
def
transform
(
expr
:
Expr
)
:
Expr
=
expr
match
{
case
v
:
Variable
=>
substs
.
getOrElse
(
v
.
to
[
V
],
super
.
transform
(
v
))
case
v
:
Variable
=>
val
res
=
substs
.
getOrElse
(
v
.
to
[
V
],
super
.
transform
(
v
))
if
(
copyPositions
)
res
.
copiedFrom
(
v
)
else
res
case
_
=>
super
.
transform
(
expr
)
case
_
=>
super
.
transform
(
expr
)
}
}
}.
transform
(
expr
)
}.
transform
(
expr
)
...
...
This diff is collapsed.
Click to expand it.
src/main/scala/inox/ast/Types.scala
+
7
−
3
View file @
ce17562d
...
@@ -336,11 +336,15 @@ trait Types { self: Trees =>
...
@@ -336,11 +336,15 @@ trait Types { self: Trees =>
case
NAryType
(
tps
,
builder
)
=>
tps
.
exists
(
isParametricType
)
case
NAryType
(
tps
,
builder
)
=>
tps
.
exists
(
isParametricType
)
}
}
def
replaceFromSymbols
[
V
<:
VariableSymbol
](
subst
:
Map
[
V
,
Expr
],
tpe
:
Type
)
def
replaceFromSymbols
[
V
<:
VariableSymbol
]
(
implicit
ev
:
VariableConverter
[
V
])
:
Type
=
{
(
subst
:
Map
[
V
,
Expr
],
tpe
:
Type
,
copyPositions
:
Boolean
=
false
)
(
implicit
ev
:
VariableConverter
[
V
])
:
Type
=
{
new
SelfTreeTransformer
{
new
SelfTreeTransformer
{
override
def
transform
(
expr
:
Expr
)
:
Expr
=
expr
match
{
override
def
transform
(
expr
:
Expr
)
:
Expr
=
expr
match
{
case
v
:
Variable
=>
subst
.
getOrElse
(
v
.
to
[
V
],
v
)
case
v
:
Variable
=>
val
res
=
subst
.
getOrElse
(
v
.
to
[
V
],
v
)
if
(
copyPositions
)
res
.
copiedFrom
(
v
)
else
res
case
_
=>
super
.
transform
(
expr
)
case
_
=>
super
.
transform
(
expr
)
}
}
}.
transform
(
tpe
)
}.
transform
(
tpe
)
...
...
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