Skip to content

Commit 3a473dd

Browse files
Merge pull request #227 from andrew-johnson-4/back-to-safety
Back to safety
2 parents 3fc2781 + ea411b0 commit 3a473dd

File tree

8 files changed

+12114
-10985
lines changed

8 files changed

+12114
-10985
lines changed

BOOTSTRAP/cli.s

Lines changed: 12058 additions & 10904 deletions
Large diffs are not rendered by default.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lambda_mountain"
3-
version = "1.11.90"
3+
version = "1.11.92"
44
authors = ["Andrew <andrew@subarctic.org>"]
55
license = "MIT"
66
description = "Lambda Mountain"

PRODUCTION/codegen-strict.lm

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@ compile-expr-strict := λctx e offset used . (tail(
9090
()
9191
( (Array( x '? )) (
9292
(if (typecheck-unify-implies( x U8 )) () (
93-
(set deref True)
94-
(set new-size (typecheck-sizeof x))
93+
(if (typecheck-unify-implies( x '? )) () (
94+
(set deref True)
95+
))
9596
))
9697
))
9798
))
@@ -159,7 +160,7 @@ compile-expr-strict := λctx e offset used . (tail(
159160
( (App( (App( (App( (Variable 'if) cond )) t )) f )) (tail(
160161
(set e1 (compile-expr-strict( ctx cond offset Used )))
161162
(set e2 (compile-expr-strict( (expr::get-context e1) t (expr::get-offset e1) Used )))
162-
(set e3 (compile-expr-strict( (expr::get-context e2) f (expr::get-offset e2) Used )))
163+
(set e3 (compile-expr-strict( (expr::get-context e1) f (expr::get-offset e1) Used )))
163164
(match (expr::get-type e1) (
164165
()
165166
(BranchConditional ())
@@ -179,6 +180,7 @@ compile-expr-strict := λctx e offset used . (tail(
179180
(local label-end)
180181
(set label-end (uuid()))
181182
(set e4 (expr::set-prog( e4 (
183+
(expr::get-frame e1)
182184
(expr::get-prog e1)
183185
\t (expr::get-expr e1) \s label-true-branch \n
184186
(expr::get-frame e3)
@@ -190,9 +192,12 @@ compile-expr-strict := λctx e offset used . (tail(
190192
(expr::get-prog e2)
191193
(expr::get-unframe e2)
192194
label-end ': \n
195+
(expr::get-unframe e1)
193196
))))
194-
(set e4 (expr::set-context( e4 (expr::get-context e3) )))
195-
(set e4 (expr::set-offset( e4 (expr::get-offset e3) )))
197+
(set e4 (expr::set-context( e4 ctx )))
198+
(set e4 (expr::set-offset( e4 offset )))
199+
(set e4 (expr::set-frame( e4 () )))
200+
(set e4 (expr::set-unframe( e4 () )))
196201
e4
197202
)))
198203
( (App( (Variable 'label) (Variable label-name) )) (

PRODUCTION/typecheck.lm

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ typecheck-ascript := λt tt . (tail(
199199
(set lt (typecheck-lookup t))
200200
(if lt (
201201
(if (typecheck-deep-eq( lt tt )) () (
202-
fail (TypeAscriptionInequality lt tt)
202+
fail (TypeAscriptionInequality lt tt t)
203203
))
204204
) (
205205
(set tt (typecheck-sizeall tt))
@@ -821,7 +821,9 @@ typecheck-infer-expr := λctx e used . (tail(
821821
()
822822
( (Array( x '? )) (
823823
(if (typecheck-unify-implies( x U8 )) () (
824-
(set rtype x)
824+
(if (typecheck-unify-implies( x '? )) () (
825+
(set rtype x)
826+
))
825827
))
826828
))
827829
))

STDLIB/default-rules.lm

Lines changed: 22 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -15,74 +15,41 @@ macro ('match-pats( term (ps (lhs rhs)) remainder )) (
1515
(match-pats(
1616
term
1717
ps
18-
(if (match-pats-condition( term lhs )) rhs remainder)
18+
(match-pats-arm( term lhs rhs remainder ))
1919
))
2020
);
2121

22-
macro ('match-pats-condition( term (:Variable: v) )) (
23-
(tail( (let v (maybe-deref term)) (branchtrue()) ))
22+
macro ('match-pats-arm( term (:Variable: v) rhs remainder )) (
23+
if (tail( (let v (maybe-deref term)) (branchtrue()) ))
24+
rhs
25+
remainder
2426
);
2527

26-
macro ('match-pats-condition( term (:Literal: l) )) (
27-
(tail( (let (uuid v) (maybe-deref term)) (==( (uuid v) l )) ))
28+
macro ('match-pats-arm( term (:Literal: l) rhs remainder )) (
29+
if (tail( (let (uuid v) (maybe-deref term)) (==( (uuid v) l )) ))
30+
rhs
31+
remainder
2832
);
2933

30-
macro ('match-pats-condition( term (:Tag: l lt) )) (
31-
(tail( (let (uuid v) (maybe-deref term)) (==( (.0( (uuid v) )) l )) ))
34+
macro ('match-pats-arm( term (:Tag: l lt) rhs remainder )) (
35+
if (tail( (let (uuid v) (maybe-deref term)) (==( (.0( (uuid v) )) l )) ))
36+
rhs
37+
remainder
3238
);
3339

34-
macro ('match-pats-condition( term ((:Tag: l lt) ( x1 )) )) (tail(
40+
macro ('match-pats-arm( term ((:Tag: l lt) ( x1 )) rhs remainder )) (tail(
3541
(let (uuid v) (maybe-deref term) )
36-
(let (uuid ok) Trueu8)
3742
(if (==( (.0( (uuid v) )) l )) (
38-
(if (match-pats-condition( (.1( (as (uuid v) lt) )) x1 )) () (set (uuid ok) Falseu8))
39-
) (set (uuid ok) Falseu8))
40-
(==( (uuid ok) Trueu8 ))
43+
(match-pats-arm( (.1( (as (uuid v) lt) )) x1 rhs remainder ))
44+
) remainder)
4145
));
4246

43-
macro ('match-pats-condition( term ((:Tag: l lt) ( x2 x1 ) ))) (tail(
47+
macro ('match-pats-arm( term ((:Tag: l lt) ( x2 x1 )) rhs remainder )) (tail(
4448
(let (uuid v) (maybe-deref term) )
45-
(let (uuid ok) Trueu8)
46-
(if (==( (.0( (uuid v) )) l )) (tail(
47-
(if (match-pats-condition( (.1( (as (uuid v) lt) )) x1 )) () (set (uuid ok) Falseu8))
48-
(if (match-pats-condition( (.2( (as (uuid v) lt) )) x2 )) () (set (uuid ok) Falseu8))
49-
)) (set (uuid ok) Falseu8))
50-
(==( (uuid ok) Trueu8 ))
51-
));
52-
53-
macro ('match-pats-condition( term ((:Tag: l lt) ( x3 x2 x1 ) ))) (tail(
54-
(let (uuid v) (maybe-deref term) )
55-
(let (uuid ok) Trueu8)
56-
(if (==( (.0( (uuid v) )) l )) (tail(
57-
(if (match-pats-condition( (.1( (as (uuid v) lt) )) x1 )) () (set (uuid ok) Falseu8))
58-
(if (match-pats-condition( (.2( (as (uuid v) lt) )) x2 )) () (set (uuid ok) Falseu8))
59-
(if (match-pats-condition( (.3( (as (uuid v) lt) )) x3 )) () (set (uuid ok) Falseu8))
60-
)) (set (uuid ok) Falseu8))
61-
(==( (uuid ok) Trueu8 ))
62-
));
63-
64-
macro ('match-pats-condition( term ((:Tag: l lt) ( x4 x3 x2 x1 ) ))) (tail(
65-
(let (uuid v) (maybe-deref term) )
66-
(let (uuid ok) Trueu8)
67-
(if (==( (.0( (uuid v) )) l )) (tail(
68-
(if (match-pats-condition( (.1( (as (uuid v) lt) )) x1 )) () (set (uuid ok) Falseu8))
69-
(if (match-pats-condition( (.2( (as (uuid v) lt) )) x2 )) () (set (uuid ok) Falseu8))
70-
(if (match-pats-condition( (.3( (as (uuid v) lt) )) x3 )) () (set (uuid ok) Falseu8))
71-
(if (match-pats-condition( (.4( (as (uuid v) lt) )) x4 )) () (set (uuid ok) Falseu8))
72-
)) (set (uuid ok) Falseu8))
73-
(==( (uuid ok) Trueu8 ))
74-
));
75-
76-
macro ('match-pats-condition( term ((:Tag: l lt) ( x5 x4 x3 x2 x1 ) ))) (tail(
77-
(let (uuid v) (maybe-deref term) )
78-
(let (uuid ok) Trueu8)
79-
(if (==( (.0( (uuid v) )) l )) (tail(
80-
(if (match-pats-condition( (.1( (as (uuid v) lt) )) x1 )) () (set (uuid ok) Falseu8))
81-
(if (match-pats-condition( (.2( (as (uuid v) lt) )) x2 )) () (set (uuid ok) Falseu8))
82-
(if (match-pats-condition( (.3( (as (uuid v) lt) )) x3 )) () (set (uuid ok) Falseu8))
83-
(if (match-pats-condition( (.4( (as (uuid v) lt) )) x4 )) () (set (uuid ok) Falseu8))
84-
(if (match-pats-condition( (.5( (as (uuid v) lt) )) x5 )) () (set (uuid ok) Falseu8))
85-
)) (set (uuid ok) Falseu8))
86-
(==( (uuid ok) Trueu8 ))
49+
(if (==( (.0( (uuid v) )) l )) (
50+
(match-pats-arm( (.1( (as (uuid v) lt) )) x1 (
51+
(match-pats-arm( (.2( (as (uuid v) lt) )) x2 rhs remainder ))
52+
) remainder ))
53+
) remainder)
8754
));
8855

STDLIB/default-stdlib.lm

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,25 @@ close := λ(: x S). (: (tail(
1010
(as R8 S[])
1111
)) S[]);
1212

13-
print := λ(: x S). (: (match x (
14-
()
15-
# ( (SAtom a) (print a) )
16-
( (SCons( l r )) (tail(
17-
()
13+
print := λ(: x S). (: (tail(
14+
(match x (
1815
()
19-
# (print '\[_s)
20-
# (print l)
21-
# (print '\s_s)
22-
# (print r)
23-
# (print '\]_s)
24-
)))
25-
# ( SNil (print '\[\]_s))
26-
# ( (SPointer p) (tail(
27-
# (print '[_s)
28-
# (print (as p U64))
29-
# (print ']_s)
30-
# )))
16+
(SNil (print '\[\]_s))
17+
( (SAtom a) (print a))
18+
( (SCons( l r )) (tail(
19+
(print '\[_s)
20+
(print l)
21+
(print '\s_s)
22+
(print r)
23+
(print '\]_s)
24+
)))
25+
( (SPointer p) (tail(
26+
(print '[_s)
27+
(print (as p U64))
28+
(print ']_s)
29+
)))
30+
))
31+
()
3132
)) Nil);
3233

3334
fail := λ(: msg Array<U8,?>). (: (tail(

tests/strict/match2.lm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ main := (tail(
1111
(2u64 (print 2u64))
1212
(3u64 (print 3u64))
1313
))
14-
()
1514
(match 2u64 (
1615
()
1716
(1u64 (print 1u64))

tests/strict/s-xp1.lm.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
()

0 commit comments

Comments
 (0)