Skip to content

Commit 412cf0e

Browse files
need to work on stack imbalance
1 parent 1937bef commit 412cf0e

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
nostd: prod
3-
./production --nostd -o tmp.s tests/strict/match2.lm
3+
./production --nostd -o tmp.s tests/strict/match6.lm
44
as -o tmp.o tmp.s
55
ld -o tmp tmp.o
66
./tmp && echo $?

PRODUCTION/codegen-strict.lm

+7-10
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ compile-expr-strict := λctx e offset used . (tail(
163163
( (App( (App( (App( (Variable 'if) cond )) t )) f )) (tail(
164164
(set e1 (compile-expr-strict( ctx cond offset Used )))
165165
(set e2 (compile-expr-strict( (expr::get-context e1) t (expr::get-offset e1) Used )))
166-
(set e3 (compile-expr-strict( (expr::get-context e2) f (expr::get-offset e2) Used )))
166+
(set e3 (compile-expr-strict( (expr::get-context e1) f (expr::get-offset e1) Used )))
167167
(match (expr::get-type e1) (
168168
()
169169
(BranchConditional ())
@@ -185,22 +185,19 @@ compile-expr-strict := λctx e offset used . (tail(
185185
(set e4 (expr::set-prog( e4 (
186186
(expr::get-prog e1)
187187
\t (expr::get-expr e1) \s label-true-branch \n
188-
(expr::get-altframe e2)
188+
(expr::get-frame e3)
189+
(expr::get-altframe e1)
189190
(expr::get-prog e3)
191+
(expr::get-unframe e3)
190192
\t 'jmp \s label-end \n
191193
label-true-branch ': \n
194+
(expr::get-frame e2)
192195
(expr::get-prog e2)
193-
(expr::get-altframe e3)
196+
(expr::get-unframe e2)
194197
label-end ': \n
195198
))))
196199
(set e4 (expr::set-context( e4 (expr::get-context e3) )))
197-
(set e4 (expr::set-offset( e4 (expr::get-offset e3) )))
198-
(set e4 (expr::set-frame( e4 (
199-
(expr::get-frame e1) (expr::get-frame e2) (expr::get-frame e3)
200-
))))
201-
(set e4 (expr::set-unframe( e4 (
202-
(expr::get-unframe e1) (expr::get-unframe e2) (expr::get-unframe e3)
203-
))))
200+
(set e4 (expr::set-offset( e4 (expr::get-offset e1) )))
204201
e4
205202
)))
206203
( (App( (Variable 'label) (Variable label-name) )) (

tests/strict/match2.lm

+7-6
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@ main := (tail(
1111
(2u64 (print 2u64))
1212
(3u64 (print 3u64))
1313
))
14+
()
1415
(match 2u64 (
1516
()
1617
(1u64 (print 1u64))
1718
(2u64 (print 2u64))
1819
(3u64 (print 3u64))
1920
))
20-
(match 3u64 (
21-
()
22-
(1u64 (print 1u64))
23-
(2u64 (print 2u64))
24-
(3u64 (print 3u64))
25-
))
21+
# (match 3u64 (
22+
# ()
23+
# (1u64 (print 1u64))
24+
# (2u64 (print 2u64))
25+
# (3u64 (print 3u64))
26+
# ))
2627
));

0 commit comments

Comments
 (0)