Skip to content

Commit

Permalink
crook
Browse files Browse the repository at this point in the history
  • Loading branch information
dvanhorn committed Nov 26, 2024
1 parent 778bbf5 commit a0131a8
Show file tree
Hide file tree
Showing 71 changed files with 673 additions and 458 deletions.
1 change: 0 additions & 1 deletion abscond/exec.rkt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#lang racket
(require a86/interp)
(require "compile.rkt")
(require "interp.rkt")
(provide exec)

;; Expr -> Integer
Expand Down
3 changes: 2 additions & 1 deletion abscond/main.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
(require "interp.rkt")
(require "compile.rkt")
(require "run.rkt")
(require "exec.rkt")
(provide (all-from-out "ast.rkt"))
(provide (all-from-out "parse.rkt"))
(provide (all-from-out "interp.rkt"))
(provide (all-from-out "compile.rkt"))
(provide (all-from-out "run.rkt"))

(provide (all-from-out "exec.rkt"))

1 change: 0 additions & 1 deletion blackmail/exec.rkt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#lang racket
(require a86/interp)
(require "compile.rkt")
(require "interp.rkt")
(provide exec)

;; Expr -> Integer
Expand Down
3 changes: 2 additions & 1 deletion blackmail/main.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
(require "interp.rkt")
(require "compile.rkt")
(require "run.rkt")
(require "exec.rkt")
(provide (all-from-out "ast.rkt"))
(provide (all-from-out "parse.rkt"))
(provide (all-from-out "interp.rkt"))
(provide (all-from-out "compile.rkt"))
(provide (all-from-out "run.rkt"))

(provide (all-from-out "exec.rkt"))

1 change: 0 additions & 1 deletion con/exec.rkt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#lang racket
(require a86/interp)
(require "compile.rkt")
(require "interp.rkt")
(provide exec)

;; Expr -> Integer
Expand Down
3 changes: 2 additions & 1 deletion con/main.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
(require "interp.rkt")
(require "compile.rkt")
(require "run.rkt")
(require "exec.rkt")
(provide (all-from-out "ast.rkt"))
(provide (all-from-out "parse.rkt"))
(provide (all-from-out "interp.rkt"))
(provide (all-from-out "compile.rkt"))
(provide (all-from-out "run.rkt"))

(provide (all-from-out "exec.rkt"))

3 changes: 1 addition & 2 deletions dodger/compile-ops.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
(Sal rax char-shift)
(Xor rax type-char))]))


;; -> Asm
;; Asm
;; set rax to #t or #f if comparison flag is equal
(define if-equal
(seq (Mov rax (value->bits #f))
Expand Down
1 change: 0 additions & 1 deletion dodger/exec.rkt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#lang racket
(require a86/interp)
(require "compile.rkt")
(require "interp.rkt")
(require "types.rkt")
(provide exec)
;; Expr -> Value
Expand Down
5 changes: 4 additions & 1 deletion dodger/main.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
(require "parse.rkt")
(require "interp.rkt")
(require "compile.rkt")
(require "types.rkt")
(require "run.rkt")
(require "exec.rkt")
(provide (all-from-out "ast.rkt"))
(provide (all-from-out "parse.rkt"))
(provide (all-from-out "interp.rkt"))
(provide (all-from-out "compile.rkt"))
(provide (all-from-out "types.rkt"))
(provide (all-from-out "run.rkt"))

(provide (all-from-out "exec.rkt"))

1 change: 0 additions & 1 deletion dupe/exec.rkt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#lang racket
(require a86/interp)
(require "compile.rkt")
(require "interp.rkt")
(require "types.rkt")
(provide exec)
;; Expr -> Value
Expand Down
5 changes: 4 additions & 1 deletion dupe/main.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
(require "parse.rkt")
(require "interp.rkt")
(require "compile.rkt")
(require "types.rkt")
(require "run.rkt")
(require "exec.rkt")
(provide (all-from-out "ast.rkt"))
(provide (all-from-out "parse.rkt"))
(provide (all-from-out "interp.rkt"))
(provide (all-from-out "compile.rkt"))
(provide (all-from-out "types.rkt"))
(provide (all-from-out "run.rkt"))

(provide (all-from-out "exec.rkt"))

3 changes: 1 addition & 2 deletions evildoer/compile-ops.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
(Mov rdi rax)
(Call 'write_byte))]))


;; -> Asm
;; Asm
;; set rax to #t or #f if comparison flag is equal
(define if-equal
(seq (Mov rax (value->bits #f))
Expand Down
1 change: 0 additions & 1 deletion evildoer/exec-io.rkt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#lang racket
(require a86/interp)
(require "compile.rkt")
(require "interp-io.rkt")
(require "types.rkt")
(require "build-runtime.rkt")
(provide exec/io)
Expand Down
1 change: 0 additions & 1 deletion evildoer/exec.rkt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#lang racket
(require a86/interp)
(require "compile.rkt")
(require "interp.rkt")
(require "types.rkt")
(require "build-runtime.rkt")
(provide exec)
Expand Down
9 changes: 8 additions & 1 deletion evildoer/main.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@
(require "ast.rkt")
(require "parse.rkt")
(require "interp.rkt")
(require "interp-io.rkt")
(require "compile.rkt")
(require "types.rkt")
(require "run.rkt")
(require "exec.rkt")
(require "exec-io.rkt")
(provide (all-from-out "ast.rkt"))
(provide (all-from-out "parse.rkt"))
(provide (all-from-out "interp.rkt"))
(provide (all-from-out "interp-io.rkt"))
(provide (all-from-out "compile.rkt"))
(provide (all-from-out "types.rkt"))
(provide (all-from-out "run.rkt"))

(provide (all-from-out "exec.rkt"))
(provide (all-from-out "exec-io.rkt"))

44 changes: 44 additions & 0 deletions extort/assert.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#lang racket
(provide assert-integer assert-char assert-byte assert-codepoint)
(require a86/ast)
(require "types.rkt")

(define r9 'r9)

;; Register -> Asm
(define (assert-integer r)
(seq (Mov r9 r)
(And r9 mask-int)
(Cmp r9 type-int)
(Jne 'err)))

;; Register -> Asm
(define (assert-char r)
(seq (Mov r9 r)
(And r9 mask-char)
(Cmp r9 type-char)
(Jne 'err)))

;; Register -> Asm
(define (assert-codepoint r)
(let ((ok (gensym)))
(seq (assert-integer r)
(Cmp r (value->bits 0))
(Jl 'err)
(Cmp r (value->bits 1114111))
(Jg 'err)
(Cmp r (value->bits 55295))
(Jl ok)
(Cmp r (value->bits 57344))
(Jg ok)
(Jmp 'err)
(Label ok))))

;; Register -> Asm
(define (assert-byte r)
(seq (assert-integer r)
(Cmp r (value->bits 0))
(Jl 'err)
(Cmp r (value->bits 255))
(Jg 'err)))

46 changes: 4 additions & 42 deletions extort/compile-ops.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
(provide compile-op0 compile-op1)
(require "ast.rkt")
(require "types.rkt")
(require "assert.rkt")
(require a86/ast)

(define rax 'rax)
Expand Down Expand Up @@ -37,61 +38,22 @@
(Sar rax char-shift)
(Sal rax int-shift))]
['integer->char
(seq (assert-codepoint)
(seq (assert-codepoint rax)
(Sar rax int-shift)
(Sal rax char-shift)
(Xor rax type-char))]
['eof-object?
(seq (Cmp rax (value->bits eof))
if-equal)]
['write-byte
(seq assert-byte
(seq (assert-byte rax)
(Mov rdi rax)
(Call 'write_byte))]))


;; -> Asm
;; Asm
;; set rax to #t or #f if comparison flag is equal
(define if-equal
(seq (Mov rax (value->bits #f))
(Mov r9 (value->bits #t))
(Cmove rax r9)))

(define (assert-type mask type)
(λ (arg)
(seq (Mov r9 arg)
(And r9 mask)
(Cmp r9 type)
(Jne 'err))))

(define (type-pred mask type)
(seq (And rax mask)
(Cmp rax type)
if-equal))

(define assert-integer
(assert-type mask-int type-int))
(define assert-char
(assert-type mask-char type-char))

(define (assert-codepoint)
(let ((ok (gensym)))
(seq (assert-integer rax)
(Cmp rax (value->bits 0))
(Jl 'err)
(Cmp rax (value->bits 1114111))
(Jg 'err)
(Cmp rax (value->bits 55295))
(Jl ok)
(Cmp rax (value->bits 57344))
(Jg ok)
(Jmp 'err)
(Label ok))))

(define assert-byte
(seq (assert-integer rax)
(Cmp rax (value->bits 0))
(Jl 'err)
(Cmp rax (value->bits 255))
(Jg 'err)))

1 change: 0 additions & 1 deletion extort/exec-io.rkt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#lang racket
(require a86/interp)
(require "compile.rkt")
(require "interp-io.rkt")
(require "types.rkt")
(require "build-runtime.rkt")
(provide exec/io)
Expand Down
1 change: 0 additions & 1 deletion extort/exec.rkt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#lang racket
(require a86/interp)
(require "compile.rkt")
(require "interp.rkt")
(require "types.rkt")
(require "build-runtime.rkt")
(provide exec)
Expand Down
5 changes: 2 additions & 3 deletions extort/interp-io.rkt
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#lang racket
(provide interp/io)
(require "interp.rkt")

;; String Expr -> (Cons Value String)
;; String Expr -> (Cons Answer String)
;; Interpret e with given string as input,
;; return value and collected output as string
;; return answer and collected output as string
(define (interp/io e input)
(define result (box #f))
(define output
Expand Down
2 changes: 2 additions & 0 deletions extort/interp.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
;; | Character
;; | Eof
;; | Void

;; type Answer = Value | 'err
;; Expr -> Answer
(define (interp e)
(match e
Expand Down
9 changes: 8 additions & 1 deletion extort/main.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@
(require "ast.rkt")
(require "parse.rkt")
(require "interp.rkt")
(require "interp-io.rkt")
(require "compile.rkt")
(require "types.rkt")
(require "run.rkt")
(require "exec.rkt")
(require "exec-io.rkt")
(provide (all-from-out "ast.rkt"))
(provide (all-from-out "parse.rkt"))
(provide (all-from-out "interp.rkt"))
(provide (all-from-out "interp-io.rkt"))
(provide (all-from-out "compile.rkt"))
(provide (all-from-out "types.rkt"))
(provide (all-from-out "run.rkt"))

(provide (all-from-out "exec.rkt"))
(provide (all-from-out "exec-io.rkt"))

44 changes: 44 additions & 0 deletions fraud/assert.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#lang racket
(provide assert-integer assert-char assert-byte assert-codepoint)
(require a86/ast)
(require "types.rkt")

(define r9 'r9)

;; Register -> Asm
(define (assert-integer r)
(seq (Mov r9 r)
(And r9 mask-int)
(Cmp r9 type-int)
(Jne 'err)))

;; Register -> Asm
(define (assert-char r)
(seq (Mov r9 r)
(And r9 mask-char)
(Cmp r9 type-char)
(Jne 'err)))

;; Register -> Asm
(define (assert-codepoint r)
(let ((ok (gensym)))
(seq (assert-integer r)
(Cmp r (value->bits 0))
(Jl 'err)
(Cmp r (value->bits 1114111))
(Jg 'err)
(Cmp r (value->bits 55295))
(Jl ok)
(Cmp r (value->bits 57344))
(Jg ok)
(Jmp 'err)
(Label ok))))

;; Register -> Asm
(define (assert-byte r)
(seq (assert-integer r)
(Cmp r (value->bits 0))
(Jl 'err)
(Cmp r (value->bits 255))
(Jg 'err)))

Loading

0 comments on commit a0131a8

Please sign in to comment.