Skip to content

Commit

Permalink
Merge recent summer changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvanhorn committed Jul 9, 2023
2 parents 8fde63b + 15ffd39 commit 805f6d0
Show file tree
Hide file tree
Showing 32 changed files with 276 additions and 245 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ University of Maryland, College Park.

The current instance of this course is:

* http://www.cs.umd.edu/class/spring2023/cmsc430/
* http://www.cs.umd.edu/class/summer2023/cmsc430/

Copyright © David Van Horn and José Manuel Calderón Trilla and Leonidas Lampropoulos

Expand Down
8 changes: 8 additions & 0 deletions langs/a86/ast.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@
(check-unique-label-decls p)
(check-label-targets-declared p)
(check-has-initial-label p)
(check-initial-label-global p)
;; anything else?
p))

Expand Down Expand Up @@ -388,6 +389,13 @@
(unless (findf Label? asm)
(error 'prog "no initial label found")))

;; Asm -> Void
(define (check-initial-label-global asm)
(match (findf Label? asm)
[(Label init)
(unless (member init (map (lambda (i) (match i [(Global l) l]))
(filter Global? asm)))
(error 'prog "initial label undeclared as global: ~v" init))]))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Symbol to Label
Expand Down
9 changes: 9 additions & 0 deletions langs/a86/test/errors.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,12 @@
(check-not-exn (thunk (Add 'rax (sub1 (expt 2 32)))))
(check-exn exn:fail? (thunk (Sub 'rax (expt 2 32))))
(check-not-exn (thunk (Sub 'rax (sub1 (expt 2 32)))))

;; Check prog
(check-exn exn:fail? (thunk (prog (Ret))))
(check-exn exn:fail? (thunk (prog (Label 'start) (Ret))))
(check-exn exn:fail? (thunk (prog (Global 'foo) (Label 'start) (Label 'foo) (Ret))))
(check-not-exn (thunk (prog (Global 'start) (Label 'start) (Ret))))
(check-not-exn (thunk (prog (Label 'start) (Ret) (Global 'start))))


2 changes: 1 addition & 1 deletion langs/abscond/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ default: submit.zip
submit.zip:
zip submit.zip -r * \
-x \*.[os] -x \*~ -x \*zip \
-x \*Zone.Identifier -x **compiled**
-x \*Zone.Identifier -x \*\*compiled\*\*

runtime.o: $(objs)
ld -r $(objs) -o runtime.o
Expand Down
2 changes: 1 addition & 1 deletion langs/blackmail/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ default: submit.zip
submit.zip:
zip submit.zip -r * \
-x \*.[os] -x \*~ -x \*zip \
-x \*Zone.Identifier -x **compiled**
-x \*Zone.Identifier -x \*\*compiled\*\*

runtime.o: $(objs)
ld -r $(objs) -o runtime.o
Expand Down
2 changes: 1 addition & 1 deletion langs/con/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ default: submit.zip
submit.zip:
zip submit.zip -r * \
-x \*.[os] -x \*~ -x \*zip \
-x \*Zone.Identifier -x **compiled**
-x \*Zone.Identifier -x \*\*compiled\*\*

runtime.o: $(objs)
ld -r $(objs) -o runtime.o
Expand Down
7 changes: 6 additions & 1 deletion langs/dodger/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ objs = \
print.o \
values.o

default: runtime.o
default: submit.zip

submit.zip:
zip submit.zip -r * \
-x \*.[os] -x \*~ -x \*zip \
-x \*Zone.Identifier -x \*\*compiled\*\*

runtime.o: $(objs)
ld -r $(objs) -o runtime.o
Expand Down
2 changes: 1 addition & 1 deletion langs/dupe/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ default: submit.zip
submit.zip:
zip submit.zip -r * \
-x \*.[os] -x \*~ -x \*zip \
-x \*Zone.Identifier -x **compiled**
-x \*Zone.Identifier -x \*\*compiled\*\*

runtime.o: $(objs)
ld -r $(objs) -o runtime.o
Expand Down
2 changes: 1 addition & 1 deletion langs/evildoer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ default: submit.zip
submit.zip:
zip submit.zip -r * \
-x \*.[os] -x \*~ -x \*zip \
-x \*Zone.Identifier -x **compiled**
-x \*Zone.Identifier -x \*\*compiled\*\*

runtime.o: $(objs)
ld -r $(objs) -o runtime.o
Expand Down
2 changes: 1 addition & 1 deletion langs/fraud/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ default: submit.zip
submit.zip:
zip submit.zip -r * \
-x \*.[os] -x \*~ -x \*zip \
-x \*Zone.Identifier -x **compiled**
-x \*Zone.Identifier -x \*\*compiled\*\*

runtime.o: $(objs)
ld -r $(objs) -o runtime.o
Expand Down
2 changes: 1 addition & 1 deletion langs/hoax/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ default: submit.zip
submit.zip:
zip submit.zip -r * \
-x \*.[os] -x \*~ -x \*zip \
-x \*Zone.Identifier -x **compiled**
-x \*Zone.Identifier -x \*\*compiled\*\*

runtime.o: $(objs)
ld -r $(objs) -o runtime.o
Expand Down
2 changes: 1 addition & 1 deletion langs/hustle/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ default: submit.zip
submit.zip:
zip submit.zip -r * \
-x \*.[os] -x \*~ -x \*zip \
-x \*Zone.Identifier -x **compiled**
-x \*Zone.Identifier -x \*\*compiled\*\*

runtime.o: $(objs)
ld -r $(objs) -o runtime.o
Expand Down
2 changes: 1 addition & 1 deletion langs/iniquity/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ default: submit.zip
submit.zip:
zip submit.zip -r * \
-x \*.[os] -x \*~ -x \*zip \
-x \*Zone.Identifier -x **compiled**
-x \*Zone.Identifier -x \*\*compiled\*\*

runtime.o: $(objs)
ld -r $(objs) -o runtime.o
Expand Down
2 changes: 1 addition & 1 deletion langs/jig/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ default: submit.zip
submit.zip:
zip submit.zip -r * \
-x \*.[os] -x \*~ -x \*zip \
-x \*Zone.Identifier -x **compiled**
-x \*Zone.Identifier -x \*\*compiled\*\*

runtime.o: $(objs)
ld -r $(objs) -o runtime.o
Expand Down
2 changes: 1 addition & 1 deletion langs/knock/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ default: submit.zip
submit.zip:
zip submit.zip -r * \
-x \*.[os] -x \*~ -x \*zip \
-x \*Zone.Identifier -x **compiled**
-x \*Zone.Identifier -x \*\*compiled\*\*

runtime.o: $(objs)
ld -r $(objs) -o runtime.o
Expand Down
2 changes: 1 addition & 1 deletion langs/loot/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ default: submit.zip
submit.zip:
zip submit.zip -r * \
-x \*.[os] -x \*~ -x \*zip \
-x \*Zone.Identifier -x **compiled**
-x \*Zone.Identifier -x \*\*compiled\*\*

runtime.o: $(objs)
ld -r $(objs) -o runtime.o
Expand Down
53 changes: 23 additions & 30 deletions langs/loot/compile.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -328,84 +328,77 @@
(define (compile-match-clause p e c done t?)
(let ((next (gensym)))
(match (compile-pattern p '() next)
[(list i f cm)
[(list i cm)
(seq (Mov rax (Offset rsp 0)) ; restore value being matched
i
(compile-e e (append cm c) t?)
(Add rsp (* 8 (length cm)))
(Jmp done)
f
(Label next))])))

;; Pat CEnv Symbol -> (list Asm Asm CEnv)
;; Pat CEnv Symbol -> (list Asm CEnv)
(define (compile-pattern p cm next)
(match p
[(PWild)
(list (seq) (seq) cm)]
(list (seq) cm)]
[(PVar x)
(list (seq (Push rax))
(seq)
(cons x cm))]
(list (seq (Push rax)) (cons x cm))]
[(PLit l)
(let ((fail (gensym)))
(let ((ok (gensym)))
(list (seq (Cmp rax (value->bits l))
(Jne fail))
(seq (Label fail)
(Je ok)
(Add rsp (* 8 (length cm)))
(Jmp next))
(Jmp next)
(Label ok))
cm))]
[(PAnd p1 p2)
(match (compile-pattern p1 (cons #f cm) next)
[(list i1 f1 cm1)
[(list i1 cm1)
(match (compile-pattern p2 cm1 next)
[(list i2 f2 cm2)
[(list i2 cm2)
(list
(seq (Push rax)
i1
(Mov rax (Offset rsp (* 8 (- (sub1 (length cm1)) (length cm)))))
i2)
(seq f1 f2)
cm2)])])]
[(PBox p)
(match (compile-pattern p cm next)
[(list i1 f1 cm1)
(let ((fail (gensym)))
[(list i1 cm1)
(let ((ok (gensym)))
(list
(seq (Mov r8 rax)
(And r8 ptr-mask)
(Cmp r8 type-box)
(Jne fail)
(Je ok)
(Add rsp (* 8 (length cm))) ; haven't pushed anything yet
(Jmp next)
(Label ok)
(Xor rax type-box)
(Mov rax (Offset rax 0))
i1)
(seq f1
(Label fail)
(Add rsp (* 8 (length cm))) ; haven't pushed anything yet
(Jmp next))
cm1))])]
[(PCons p1 p2)
(match (compile-pattern p1 (cons #f cm) next)
[(list i1 f1 cm1)
[(list i1 cm1)
(match (compile-pattern p2 cm1 next)
[(list i2 f2 cm2)
(let ((fail (gensym)))
[(list i2 cm2)
(let ((ok (gensym)))
(list
(seq (Mov r8 rax)
(And r8 ptr-mask)
(Cmp r8 type-cons)
(Jne fail)
(Je ok)
(Add rsp (* 8 (length cm))) ; haven't pushed anything yet
(Jmp next)
(Label ok)
(Xor rax type-cons)
(Mov r8 (Offset rax 0))
(Push r8) ; push cdr
(Mov rax (Offset rax 8)) ; mov rax car
i1
(Mov rax (Offset rsp (* 8 (- (sub1 (length cm1)) (length cm)))))
i2)
(seq f1
f2
(Label fail)
(Add rsp (* 8 (length cm))) ; haven't pushed anything yet
(Jmp next))
cm2))])])]))

;; Id CEnv -> Integer
Expand Down
2 changes: 1 addition & 1 deletion langs/mountebank/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ default: submit.zip
submit.zip:
zip submit.zip -r * \
-x \*.[os] -x \*~ -x \*zip \
-x \*Zone.Identifier -x **compiled**
-x \*Zone.Identifier -x \*\*compiled\*\*

runtime.o: $(objs)
ld -r $(objs) -o runtime.o
Expand Down
Loading

0 comments on commit 805f6d0

Please sign in to comment.