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
67178875
Commit
67178875
authored
Apr 19, 2021
by
Sapphie
Browse files
debugging and testing
parent
e6899d1b
Changes
2
Hide whitespace changes
Inline
Side-by-side
compiler/src/l3/CPSValueRepresenter.scala
View file @
67178875
...
...
@@ -37,13 +37,14 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) {
if
(
knownFuns
.
contains
(
fName
))
{
val
(
wName
,
sName
,
fvs
)
=
knownFuns
(
fName
)
val
newArgs
=
(
args
map
rewrite
)
++
(
fvs
map
L
.
AtomN
)
L
.
AppF
(
L
.
AtomN
(
wName
),
retC
,
newArgs
)
val
res
=
L
.
AppF
(
L
.
AtomN
(
wName
),
retC
,
newArgs
)
res
}
else
{
val
f
=
Symbol
.
fresh
(
"
f
"
)
val
f
=
Symbol
.
fresh
(
"
closure
"
)
val
newBody
=
L
.
AppF
(
L
.
AtomN
(
f
),
retC
,
rewrite
(
fun
)
+:
args
.
map
(
rewrite
))
val
newArgs
=
Seq
(
rewrite
(
fun
),
L
.
AtomL
(
0
))
val
res
=
L
.
LetP
(
f
,
CPS
.
BlockGet
,
newArgs
,
newBody
)
println
(
"
satoeuhsoethu
"
)
println
(
"
aaaaaaaaaaaa
"
)
println
(
fName
)
println
(
res
)
res
...
...
@@ -358,7 +359,12 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) {
case
L3
.
CharToInt
=>
L
.
LetP
(
n
,
CPS
.
ShiftRight
,
Seq
(
rewrite
(
x
),
L
.
AtomL
(
2
)),
transform
(
body
))
case
L3
.
Id
=>
L
.
LetP
(
n
,
CPS
.
Id
,
Seq
(
rewrite
(
x
)),
transform
(
body
))
val
newKnownFuns
=
x
match
{
case
H
.
AtomN
(
xName
)
if
knownFuns
contains
xName
=>
knownFuns
.
updated
(
n
,
knownFuns
(
xName
))
case
_
=>
knownFuns
}
L
.
LetP
(
n
,
CPS
.
Id
,
Seq
(
rewrite
(
x
)),
transform
(
body
)(
newKnownFuns
))
case
L3
.
IntToChar
=>
tempLetP
(
CPS
.
ShiftLeft
,
Seq
(
Left
(
x
),
Right
(
L
.
AtomL
(
2
)))){
t1
=>
...
...
tests/expr-fun.l3
View file @
67178875
...
...
@@ -11,11 +11,19 @@
;; 66)
;;(@byte-write ((fun (x) x) 68))
(let ((compose (fun (f g)
(fun (x) (f (g x)))))
(succ (fun (x) (@+ x 1)))
(twice (fun (x) (@+ x x))))
(@byte-write ((compose succ twice) 34)))
;;(let ((compose (fun (f g)
;; (fun (x) (f (g x)))))
;; (succ (fun (x) (@+ x 1)))
;; (twice (fun (x) (@+ x x))))
;; (@byte-write ((compose succ twice) 34)))
(let
(
(compose (fun (f)
(fun (x) (f x)))
)
)
((compose 1)))
;;((fun (x y z) #u)
;; (@byte-write 70)
...
...
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