diff --git a/parse-bytecode-5.1.1.rkt b/parse-bytecode-5.1.1.rkt index bdd3aaa..c3dd237 100644 --- a/parse-bytecode-5.1.1.rkt +++ b/parse-bytecode-5.1.1.rkt @@ -407,10 +407,13 @@ (make-Constant rand)])) - - (define (parse-branch expr) - (error 'fixme)) + (match expr + [(struct branch (test then else)) + (make-Branch (parse-expr-seq-constant test) + (parse-expr-seq-constant then) + (parse-expr-seq-constant else))])) + (define (parse-with-cont-mark expr) (error 'fixme)) diff --git a/test-parse-bytecode-5.1.1.rkt b/test-parse-bytecode-5.1.1.rkt index ffd2203..f221238 100644 --- a/test-parse-bytecode-5.1.1.rkt +++ b/test-parse-bytecode-5.1.1.rkt @@ -123,8 +123,20 @@ (make-LocalRef 0 #f))))) +(check-equal? (run-my-parse #'(if (f) (g) (h))) + (make-Top (make-Prefix (list (make-GlobalBucket 'f) + (make-GlobalBucket 'g) + (make-GlobalBucket 'h))) + (make-Branch (make-App (make-ToplevelRef 0 0) '()) + (make-App (make-ToplevelRef 0 1) '()) + (make-App (make-ToplevelRef 0 2) '())))) +;; Another example where Racket's compiler is helping: constant propagation, dead code removal. +(check-equal? (run-my-parse #'(if 3 (g) (h))) + (make-Top (make-Prefix (list (make-GlobalBucket 'g))) + (make-App (make-ToplevelRef 0 0) '()))) +