Skip to content

Commit aa1ebdf

Browse files
committed
Complete compiler can compile itself (but crashes when run).
1 parent 1b75e04 commit aa1ebdf

File tree

5 files changed

+26
-28
lines changed

5 files changed

+26
-28
lines changed

langs/outlaw/compile-stdin.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#lang racket
2-
(require "parse.rkt" "compile.rkt" "read-all.rkt" "a86/printer.rkt")
2+
(require "stdlib.rkt" "parse.rkt" "compile.rkt" "read-all.rkt" "a86/printer.rkt")
33
(provide main)
44

55
;; -> Void

langs/outlaw/compile.rkt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,18 @@
5858
'(list list* make-list list? foldr map filter length append append*
5959
memq member append-map vector->list
6060
reverse
61-
number->string gensym read read-char
61+
number->string gensym read read-char peek-char
6262
> <= >=
6363
void?
6464
list->string string->list
65-
char<=?
65+
char<=? char=?
6666
remove-duplicates remq* remove* remove
6767
andmap vector list->vector boolean?
6868
substring odd?
6969
system-type ;; hard-coded
7070
not findf
7171
read-line
72+
exact->inexact / expt string->keyword ; unimplemented
7273
;; Op0
7374
read-byte peek-byte void
7475
;; Op1

langs/outlaw/read.rkt

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#lang racket
22
(provide read)
3-
(require "stdlib.rkt")
3+
(require "stdlib.rkt" "utils.rkt")
44
;(require (only-in "stdlib.rkt" read-char))
55

66
;; read.rkt
@@ -673,23 +673,3 @@
673673

674674
(define (unimplemented x)
675675
(err (string-append "unimplemented: " x)))
676-
677-
678-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
679-
;; Multipliers
680-
681-
(define (*2 a)
682-
(arithmetic-shift a 1))
683-
684-
(define (*8 a)
685-
(arithmetic-shift a 3))
686-
687-
(define (*16 a)
688-
(arithmetic-shift a 4))
689-
690-
(define (*10 a) ; 10a=2^3a+2a
691-
(+ (arithmetic-shift a 1)
692-
(arithmetic-shift a 3)))
693-
694-
(define (*64 a)
695-
(arithmetic-shift a 6))

langs/outlaw/stdlib.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#lang racket
22
(provide list list* make-list list? map foldr filter length append append*
33
memq member append-map vector->list
4-
number->string gensym read read-char
4+
number->string gensym read read-char peek-char
55
> <= >= void?
66
char<=? char=?
77
list->string string->list

langs/outlaw/utils.rkt

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#lang racket
2-
(provide symbol->label symbol->data-label lookup pad-stack unpad-stack *8)
2+
(provide symbol->label symbol->data-label lookup pad-stack unpad-stack *2 *8 *10 *16 *64)
33
(require "a86/ast.rkt" "registers.rkt")
44

55
;; Symbol -> Label
@@ -49,5 +49,22 @@
4949
(define (unpad-stack)
5050
(seq (Add rsp r15)))
5151

52-
(define (*8 n)
53-
(arithmetic-shift n 3))
52+
53+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
54+
;; Multipliers
55+
56+
(define (*2 a)
57+
(arithmetic-shift a 1))
58+
59+
(define (*8 a)
60+
(arithmetic-shift a 3))
61+
62+
(define (*16 a)
63+
(arithmetic-shift a 4))
64+
65+
(define (*10 a) ; 10a=2^3a+2a
66+
(+ (arithmetic-shift a 1)
67+
(arithmetic-shift a 3)))
68+
69+
(define (*64 a)
70+
(arithmetic-shift a 6))

0 commit comments

Comments
 (0)