Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Haley Sapphie Owsianko
ACC-project
Commits
0ddd02df
Commit
0ddd02df
authored
Apr 14, 2021
by
Luca Bataillard
Browse files
add function name to worker var substition
parent
a5800231
Changes
1
Hide whitespace changes
Inline
Side-by-side
compiler/src/l3/CPSValueRepresenter.scala
View file @
0ddd02df
...
...
@@ -44,7 +44,7 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) {
val
fv
=
((
freeVars
(
f
.
body
)
-
f
.
name
)
--
f
.
args
).
toList
// Creates a letP
def
argsBindings
(
freeVars
:
Seq
[
Symbol
],
counter
:
Int
,
accSubst
:
Map
[
Symbol
,
Symbol
])
:
L.Tree
=
freeVars
match
{
def
argsBindings
(
freeVars
:
Seq
[
Symbol
],
counter
:
Int
,
accSubst
:
Subst
[
Symbol
])
:
L.Tree
=
freeVars
match
{
case
Nil
=>
substitute
(
funBody
)(
accSubst
)
case
freeVar
::
vs
=>
...
...
@@ -54,7 +54,7 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) {
argsBindings
(
vs
,
counter
+
1
,
accSubst
+
(
freeVar
->
v
)))
}
val
newFunBody
=
argsBindings
(
fv
,
1
,
Map
(
))
val
newFunBody
=
argsBindings
(
fv
,
1
,
subst
(
f
.
name
,
envName
))
val
newFun
=
L
.
Fun
(
workerFun
,
f
.
retC
,
newArgs
,
newFunBody
)
(
newFun
,
fv
,
f
.
name
)
+:
transformFunAbs
(
fs
)
}
...
...
@@ -92,7 +92,7 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) {
// Substitutes _free_ variables in `tree`
// meaning that `subst` should only contain variables
// that are free in `tree`
def
substitute
(
tree
:
L.Tree
)(
implicit
subst
:
Map
[
Symbol
,
Symbol
])
:
L.Tree
=
{
def
substitute
(
tree
:
L.Tree
)(
implicit
subst
:
Subst
[
Symbol
])
:
L.Tree
=
{
def
subtituteArgs
(
args
:
Seq
[
L.Atom
])
:
Seq
[
L.Atom
]
=
args
.
map
(
substituteAtom
)
def
substituteAtom
(
atom
:
L.Atom
)
=
atom
match
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment