Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions dupe-plus-plus/compile.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
(match e
[(Lit d) (compile-datum d)]
[(Prim1 p e) (compile-prim1 p e)]
[(If e1 e2 e3)
(compile-if e1 e2 e3)]
[(If e1 e2 e3) (compile-if e1 e2 e3)]
[(Cond eqs eas el) ;; TODO
(seq)]
[(Case e ds es el) ;; TODO
Expand Down
3 changes: 1 addition & 2 deletions dupe-plus/compile.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
(match e
[(Lit d) (compile-datum d)]
[(Prim1 p e) (compile-prim1 p e)]
[(If e1 e2 e3)
(compile-if e1 e2 e3)]
[(If e1 e2 e3) (compile-if e1 e2 e3)]
[(Cond eqs eas el) ;; TODO
(seq)]))

Expand Down
7 changes: 4 additions & 3 deletions extort-plus/compile-ops.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
(define (compile-op0 p)
(match p
['void (seq (Mov rax (value->bits (void))))]
['read-byte (seq (Call 'read_byte))]
['peek-byte (seq (Call 'peek_byte))]))
['read-byte (seq (Extern 'read_byte) (Call 'read_byte))]
['peek-byte (seq (Extern 'peek_byte) (Call 'peek_byte))]))

;; Op1 -> Asm
(define (compile-op1 p)
Expand Down Expand Up @@ -51,7 +51,8 @@
(seq (Cmp rax (value->bits eof))
if-equal)]
['write-byte
(seq (assert-byte rax)
(seq (Extern 'write_byte)
(assert-byte rax)
(Mov rdi rax)
(Call 'write_byte))]))

Expand Down
11 changes: 3 additions & 8 deletions extort-plus/compile.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,14 @@
;; Expr -> Asm
(define (compile e)
(prog (Global 'entry)
(Extern 'peek_byte)
(Extern 'read_byte)
(Extern 'write_byte)
(Extern 'raise_error)
(Label 'entry)
(Sub rsp 8)
(compile-e e)
(Add rsp 8)
(Ret)
;; Error handler
(Label 'err)
(Extern 'raise_error)
(Call 'raise_error)))

;; Expr -> Asm
Expand All @@ -30,14 +27,12 @@
[(Eof) (seq (Mov rax (value->bits eof)))]
[(Prim0 p) (compile-prim0 p)]
[(Prim1 p e) (compile-prim1 p e)]
[(If e1 e2 e3)
(compile-if e1 e2 e3)]
[(If e1 e2 e3) (compile-if e1 e2 e3)]
[(Cond eqs eas el) ;; TODO
(seq)]
[(Case e ds es el) ;; TODO
(seq)]
[(Begin e1 e2)
(compile-begin e1 e2)]))
[(Begin e1 e2) (compile-begin e1 e2)]))

;; Datum -> Asm
(define (compile-datum d)
Expand Down
7 changes: 4 additions & 3 deletions fraud-plus/compile-ops.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
(define (compile-op0 p)
(match p
['void (seq (Mov rax (value->bits (void))))]
['read-byte (seq pad-stack (Call 'read_byte) unpad-stack)]
['peek-byte (seq pad-stack (Call 'peek_byte) unpad-stack)]))
['read-byte (seq (Extern 'read_byte) pad-stack (Call 'read_byte) unpad-stack)]
['peek-byte (seq (Extern 'peek_byte) pad-stack (Call 'peek_byte) unpad-stack)]))

;; Op1 -> Asm
(define (compile-op1 p)
Expand Down Expand Up @@ -57,7 +57,8 @@
(seq (Cmp rax (value->bits eof))
if-equal)]
['write-byte
(seq (assert-byte rax)
(seq (Extern 'write_byte)
(assert-byte rax)
pad-stack
(Mov rdi rax)
(Call 'write_byte)
Expand Down
11 changes: 3 additions & 8 deletions fraud-plus/compile.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
;; ClosedExpr -> Asm
(define (compile e)
(prog (Global 'entry)
(Extern 'peek_byte)
(Extern 'read_byte)
(Extern 'write_byte)
(Extern 'raise_error)
(Label 'entry)
;; save callee-saved register
(Push r15)
Expand All @@ -23,6 +19,7 @@
;; Error handler
(Label 'err)
pad-stack
(Extern 'raise_error)
(Call 'raise_error)))

;; type CEnv = (Listof [Maybe Id])
Expand All @@ -35,8 +32,7 @@
[(Prim0 p) (compile-prim0 p)]
[(Prim1 p e) (compile-prim1 p e c)]
[(Prim2 p e1 e2) (compile-prim2 p e1 e2 c)]
[(If e1 e2 e3)
(compile-if e1 e2 e3 c)]
[(If e1 e2 e3) (compile-if e1 e2 e3 c)]
[(Cond eqs eas el) ;; TODO
(seq)]
[(Case e ds es el) ;; TODO
Expand All @@ -49,8 +45,7 @@
;; TODO: this works for special case of single binding
;; TODO: revise to work for any number of bindings
(compile-let1 x e1 e c)]
[(Begin e1 e2)
(compile-begin e1 e2 c)]))
[(Begin e1 e2) (compile-begin e1 e2 c)]))

;; Datum -> Asm
(define (compile-datum d)
Expand Down
7 changes: 4 additions & 3 deletions hoax-plus/compile-ops.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
(define (compile-op0 p)
(match p
['void (seq (Mov rax (value->bits (void))))]
['read-byte (seq pad-stack (Call 'read_byte) unpad-stack)]
['peek-byte (seq pad-stack (Call 'peek_byte) unpad-stack)]))
['read-byte (seq (Extern 'read_byte) pad-stack (Call 'read_byte) unpad-stack)]
['peek-byte (seq (Extern 'peek_byte) pad-stack (Call 'peek_byte) unpad-stack)]))

;; Op1 -> Asm
(define (compile-op1 p)
Expand Down Expand Up @@ -42,7 +42,8 @@
(seq (Cmp rax (value->bits eof))
if-equal)]
['write-byte
(seq (assert-byte rax)
(seq (Extern 'write_byte)
(assert-byte rax)
pad-stack
(Mov rdi rax)
(Call 'write_byte)
Expand Down
14 changes: 4 additions & 10 deletions hoax-plus/compile.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
;; ClosedExpr -> Asm
(define (compile e)
(prog (Global 'entry)
(Extern 'peek_byte)
(Extern 'read_byte)
(Extern 'write_byte)
(Extern 'raise_error)
(Label 'entry)
;; save callee-saved register
(Push r15)
Expand All @@ -27,6 +23,7 @@
;; Error handler
(Label 'err)
pad-stack
(Extern 'raise_error)
(Call 'raise_error)
(Data)
(Label 'empty)
Expand All @@ -43,12 +40,9 @@
[(Prim1 p e) (compile-prim1 p e c)]
[(Prim2 p e1 e2) (compile-prim2 p e1 e2 c)]
[(Prim3 p e1 e2 e3) (compile-prim3 p e1 e2 e3 c)]
[(If e1 e2 e3)
(compile-if e1 e2 e3 c)]
[(Begin e1 e2)
(compile-begin e1 e2 c)]
[(Let x e1 e2)
(compile-let x e1 e2 c)]))
[(If e1 e2 e3) (compile-if e1 e2 e3 c)]
[(Begin e1 e2) (compile-begin e1 e2 c)]
[(Let x e1 e2) (compile-let x e1 e2 c)]))

;; Datum -> Asm
(define (compile-datum d)
Expand Down
7 changes: 4 additions & 3 deletions iniquity-plus/compile-ops.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
(define (compile-op0 p)
(match p
['void (seq (Mov rax (value->bits (void))))]
['read-byte (seq pad-stack (Call 'read_byte) unpad-stack)]
['peek-byte (seq pad-stack (Call 'peek_byte) unpad-stack)]))
['read-byte (seq (Extern 'read_byte) pad-stack (Call 'read_byte) unpad-stack)]
['peek-byte (seq (Extern 'peek_byte) pad-stack (Call 'peek_byte) unpad-stack)]))

;; Op1 -> Asm
(define (compile-op1 p)
Expand Down Expand Up @@ -42,7 +42,8 @@
(seq (Cmp rax (value->bits eof))
if-equal)]
['write-byte
(seq (assert-byte rax)
(seq (Extern 'write_byte)
(assert-byte rax)
pad-stack
(Mov rdi rax)
(Call 'write_byte)
Expand Down
17 changes: 5 additions & 12 deletions iniquity-plus/compile.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
(match p
[(Prog ds e)
(prog (Global 'entry)
(Extern 'peek_byte)
(Extern 'read_byte)
(Extern 'write_byte)
(Extern 'raise_error)
(Label 'entry)
(Push rbx) ; save callee-saved register
(Push r15)
Expand All @@ -30,6 +26,7 @@
(compile-defines ds)
(Label 'err)
pad-stack
(Extern 'raise_error)
(Call 'raise_error)
(Data)
(Label 'empty)
Expand Down Expand Up @@ -74,14 +71,10 @@
[(Prim1 p e) (compile-prim1 p e c)]
[(Prim2 p e1 e2) (compile-prim2 p e1 e2 c)]
[(Prim3 p e1 e2 e3) (compile-prim3 p e1 e2 e3 c)]
[(If e1 e2 e3)
(compile-if e1 e2 e3 c)]
[(Begin e1 e2)
(compile-begin e1 e2 c)]
[(Let x e1 e2)
(compile-let x e1 e2 c)]
[(App f es)
(compile-app f es c)]
[(If e1 e2 e3) (compile-if e1 e2 e3 c)]
[(Begin e1 e2) (compile-begin e1 e2 c)]
[(Let x e1 e2) (compile-let x e1 e2 c)]
[(App f es) (compile-app f es c)]
[(Apply f es e)
(compile-apply f es e c)]))

Expand Down
7 changes: 4 additions & 3 deletions knock-plus/compile-ops.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
(define (compile-op0 p)
(match p
['void (seq (Mov rax (value->bits (void))))]
['read-byte (seq pad-stack (Call 'read_byte) unpad-stack)]
['peek-byte (seq pad-stack (Call 'peek_byte) unpad-stack)]))
['read-byte (seq (Extern 'read_byte) pad-stack (Call 'read_byte) unpad-stack)]
['peek-byte (seq (Extern 'peek_byte) pad-stack (Call 'peek_byte) unpad-stack)]))

;; Op1 -> Asm
(define (compile-op1 p)
Expand Down Expand Up @@ -42,7 +42,8 @@
(seq (Cmp rax (value->bits eof))
if-equal)]
['write-byte
(seq (assert-byte rax)
(seq (Extern 'write_byte)
(assert-byte rax)
pad-stack
(Mov rdi rax)
(Call 'write_byte)
Expand Down
17 changes: 5 additions & 12 deletions knock-plus/compile.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
(match p
[(Prog ds e)
(prog (Global 'entry)
(Extern 'peek_byte)
(Extern 'read_byte)
(Extern 'write_byte)
(Extern 'raise_error)
(Label 'entry)
(Push rbx) ; save callee-saved register
(Push r15)
Expand All @@ -32,6 +28,7 @@
(compile-defines ds)
(Label 'err)
pad-stack
(Extern 'raise_error)
(Call 'raise_error)
(Data)
(Label 'empty)
Expand Down Expand Up @@ -66,14 +63,10 @@
[(Prim2 p e1 e2) (compile-prim2 p e1 e2 c)]
[(Prim3 p e1 e2 e3) (compile-prim3 p e1 e2 e3 c)]
[(PrimN p es) (compile-primN p es c)]
[(If e1 e2 e3)
(compile-if e1 e2 e3 c t?)]
[(Begin e1 e2)
(compile-begin e1 e2 c t?)]
[(Let x e1 e2)
(compile-let x e1 e2 c t?)]
[(App f es)
(compile-app f es c t?)]
[(If e1 e2 e3) (compile-if e1 e2 e3 c t?)]
[(Begin e1 e2) (compile-begin e1 e2 c t?)]
[(Let x e1 e2) (compile-let x e1 e2 c t?)]
[(App f es) (compile-app f es c t?)]
[(Match e ps es) (compile-match e ps es c t?)]))

;; Datum -> Asm
Expand Down