Skip to content
GitLab
Menu
Projects
Groups
Snippets
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
418c23de
Commit
418c23de
authored
May 07, 2021
by
Sapphie
Browse files
Fix halt untagging
parent
a38f59ae
Changes
2
Hide whitespace changes
Inline
Side-by-side
compiler/src/l3/CPSValueRepresenter.scala
View file @
418c23de
...
...
@@ -34,7 +34,6 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) {
case
H
.
AtomL
(
CharLit
(
c
))
=>
L
.
Halt
(
L
.
AtomL
(
c
.
toInt
))
case
H
.
AtomL
(
BooleanLit
(
b
))
=>
L
.
Halt
(
L
.
AtomL
(
if
(
b
)
1
else
0
))
case
v1
@
H
.
AtomN
(
_
)
=>
return
L
.
Halt
(
rewrite
(
v
))
val
haltContName
=
Symbol
.
fresh
(
"c-halt"
)
val
haltContArgs
=
Seq
(
Symbol
.
fresh
(
"halt_arg"
))
val
haltContBody
=
L
.
Halt
(
L
.
AtomN
(
haltContArgs
(
0
)))
...
...
@@ -65,9 +64,9 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) {
val
contName
=
Symbol
.
fresh
(
"c-"
+
name
)
val
argName
=
Symbol
.
fresh
(
name
+
"_arg"
)
val
shiftedName
=
Symbol
.
fresh
(
name
+
"_arg_untagged"
)
L
.
Cnt
(
contName
,
Seq
(
argName
),
L
.
Cnt
(
contName
,
Seq
(),
L
.
LetP
(
shiftedName
,
CPS
.
ShiftRight
,
Seq
(
L
.
AtomN
(
argName
),
L
.
AtomL
(
nBitsShift
)),
Seq
(
rewrite
(
v
),
L
.
AtomL
(
nBitsShift
)),
L
.
AppC
(
haltCont
,
Seq
(
L
.
AtomN
(
shiftedName
)))))
}
...
...
@@ -94,7 +93,7 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) {
transformIf
(
L3
.
CharP
,
Seq
(
v
),
untagCharCont
.
name
,
boolCheckCont
.
name
))
//etc
val
letCBody
=
transformIf
(
L3
.
IntP
,
Seq
(
v
),
untagIntCont
.
name
,
ha
ltCont
)
val
letCBody
=
transformIf
(
L3
.
IntP
,
Seq
(
v
),
untagIntCont
.
name
,
c
ha
rCheckCont
.
name
)
val
conts
=
Seq
(
untagIntCont
,
untagCharCont
,
...
...
examples/haltuntag.l3
View file @
418c23de
(halt (@- 1 1))
\ No newline at end of file
(let ((p (@byte-read))) (let ((p_1 (@- p 48))) (halt p_1)))
\ No newline at end of file
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