From 4be57c1e370a5f5a88d1adb004eff9f622d41034 Mon Sep 17 00:00:00 2001 From: Danny Yoo Date: Mon, 9 May 2011 16:38:32 -0400 Subject: [PATCH] branch --- parse-bytecode-5.1.1.rkt | 9 ++++++--- test-parse-bytecode-5.1.1.rkt | 12 ++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) 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) '()))) +