Skip to content

Commit bf6d1f2

Browse files
Merge pull request #218 from andrew-johnson-4/strict-compiler-dev-3-4
Strict compiler dev 3 4
2 parents 6166a58 + f9d3944 commit bf6d1f2

File tree

10 files changed

+9703
-9506
lines changed

10 files changed

+9703
-9506
lines changed

BOOTSTRAP/cli.s

+9,659-9,488
Large diffs are not rendered by default.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lambda_mountain"
3-
version = "1.11.81"
3+
version = "1.11.82"
44
authors = ["Andrew <andrew@subarctic.org>"]
55
license = "MIT"
66
description = "Lambda Mountain"

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/ifeq.lm
3+
./production --nostd -o tmp.s tests/strict/ifstreq.lm
44
as -o tmp.o tmp.s
55
ld -o tmp tmp.o
66
./tmp && echo $?

PRODUCTION/stack.lm

+1-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ stack-define-destructure := λ ctx lhs offset . (match lhs (
228228
(local return)
229229
(set return (expr::new()))
230230
(set return (expr::set-context( return ctx )))
231-
(set return (expr::set-offset( return (i2s new_offset) )))
231+
(set return (expr::set-offset( return (expr::get-offset more-e) )))
232232
return
233233
)))
234234
( u (fail (UnknownStackArg lhs)))

STDLIB/default-instruction-set.lm

+12
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,18 @@ fragment mov := λ(: src Reg64)(: index Literal+Constant)(: dst LocalVariable+Si
9797
\t 'movq \s (*( word-offset 8 )) \[ '%r14 \] , '%r15 \n
9898
\t 'movq \s '%r15 , \s (+( (.expression dst) (*( word-offset 8 )) )) \[ '%rbp \] \n
9999
))
100+
(if-eq size 4 (
101+
\t 'movq \s '0 \[ '%r14 \] , \s '%r15 \n
102+
\t 'movq \s '%r15 , \s (.expression dst) \[ '%rbp \] \n
103+
))
104+
(if-eq size 2 (
105+
\t 'movq \s '0 \[ '%r14 \] , \s '%r15 \n
106+
\t 'movq \s '%r15 , \s (.expression dst) \[ '%rbp \] \n
107+
))
108+
(if-eq size 1 (
109+
\t 'movq \s '0 \[ '%r14 \] , \s '%r15 \n
110+
\t 'movq \s '%r15 , \s (.expression dst) \[ '%rbp \] \n
111+
))
100112
))
101113
) Nil);
102114

STDLIB/default-stdlib.lm

+9-13
Original file line numberDiff line numberDiff line change
@@ -189,20 +189,16 @@ print := λ(: x I8). (: (tail(
189189
(gensym-label end-true)
190190
(gensym-label end-false)
191191
(gensym-label end)
192-
# (mov( l R15 ))
193-
# (mov( r R14 ))
194-
# (label start )
195-
# (mov( R15 0u64 c1 ))
196-
# (mov( R14 0u64 c2 ))
197-
# (push R14)
198-
# (push R15)
192+
(mov( l R8 ))
193+
(mov( r R9 ))
194+
(label start )
195+
(mov( R8 0u64 c1 ))
196+
(mov( R9 0u64 c2 ))
199197
(if (==( c1 c2 )) () (jmp end-false))
200-
# (if (==( c1 0u8 )) () (jmp end-true))
201-
# (pop R15)
202-
# (pop R14)
203-
# (inc R14)
204-
# (inc R15)
205-
# (jmp start)
198+
(if (==( c1 0u8 )) () (jmp end-true))
199+
(inc R8)
200+
(inc R9)
201+
(jmp start)
206202
(label end-true)
207203
(mov( 1u64 RAX ))
208204
(jmp( end ))

tests/strict/ifeq.lm

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ main := (tail(
1414
(print x)(print y)(print \n_s)
1515
(if (==( x y )) (print 'Failure\n_s) (print 'ZeroNotEqualOne\n_s) )
1616
))
17-
()
1817
(tail(
1918
(let x 0u16)
2019
(let y 0u16)

tests/strict/ifstreq.lm

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
import STDLIB/default-instruction-set.lm;
3+
import STDLIB/default-primitives.lm;
4+
import STDLIB/default-rules.lm;
5+
import STDLIB/default-stdlib.lm;
6+
7+
main := (tail(
8+
(let x 'a_s)
9+
(let y 'a_s)
10+
(print x)(print y)(print \n_s)
11+
(if (==( x y )) (print 'AEqA\n_s) (print 'Failure\n_s) )
12+
(set y 'b_s)
13+
(print x)(print y)(print \n_s)
14+
(if (==( x y )) (print 'Failure\n_s) (print 'ANotEqB\n_s) )
15+
));

tests/strict/ifstreq.lm.out

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
aa
2+
AEqA
3+
ab
4+
ANotEqB

tests/strict/match3.lm.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
abcabcabc
1+
abc

0 commit comments

Comments
 (0)