From 98f778ea28b7df3def9da6f7447f5f6c5fc9c6c9 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Tue, 28 May 2013 12:28:56 -0400 Subject: [PATCH] Rewrite unparse-tree-il to use the Wright matcher. * module/language/tree-il.scm (unparse-tree-il): Rewrite to use the Wright matcher. --- module/language/tree-il.scm | 62 ++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/module/language/tree-il.scm b/module/language/tree-il.scm index 7ed2c7bab..b40224b2f 100644 --- a/module/language/tree-il.scm +++ b/module/language/tree-il.scm @@ -273,91 +273,95 @@ (error "unrecognized tree-il" exp))))) (define (unparse-tree-il tree-il) - (record-case tree-il - (() + (match tree-il + (($ src) '(void)) - (( proc args) + (($ src proc args) `(call ,(unparse-tree-il proc) ,@(map unparse-tree-il args))) - (( name args) + (($ src name args) `(primcall ,name ,@(map unparse-tree-il args))) - (( test consequent alternate) - `(if ,(unparse-tree-il test) ,(unparse-tree-il consequent) ,(unparse-tree-il alternate))) + (($ src test consequent alternate) + `(if ,(unparse-tree-il test) + ,(unparse-tree-il consequent) + ,(unparse-tree-il alternate))) - (( name) + (($ src name) `(primitive ,name)) - (( name gensym) + (($ src name gensym) `(lexical ,name ,gensym)) - (( name gensym exp) + (($ src name gensym exp) `(set! (lexical ,name ,gensym) ,(unparse-tree-il exp))) - (( mod name public?) + (($ src mod name public?) `(,(if public? '@ '@@) ,mod ,name)) - (( mod name public? exp) + (($ src mod name public? exp) `(set! (,(if public? '@ '@@) ,mod ,name) ,(unparse-tree-il exp))) - (( name) + (($ src name) `(toplevel ,name)) - (( name exp) + (($ src name exp) `(set! (toplevel ,name) ,(unparse-tree-il exp))) - (( name exp) + (($ src name exp) `(define ,name ,(unparse-tree-il exp))) - (( meta body) + (($ src meta body) (if body `(lambda ,meta ,(unparse-tree-il body)) `(lambda ,meta (lambda-case)))) - (( req opt rest kw inits gensyms body alternate) + (($ src req opt rest kw inits gensyms body alternate) `(lambda-case ((,req ,opt ,rest ,kw ,(map unparse-tree-il inits) ,gensyms) ,(unparse-tree-il body)) . ,(if alternate (list (unparse-tree-il alternate)) '()))) - (( exp) + (($ src exp) `(const ,exp)) - (( head tail) + (($ src head tail) `(seq ,(unparse-tree-il head) ,(unparse-tree-il tail))) - (( names gensyms vals body) + (($ src names gensyms vals body) `(let ,names ,gensyms ,(map unparse-tree-il vals) ,(unparse-tree-il body))) - (( in-order? names gensyms vals body) + (($ src in-order? names gensyms vals body) `(,(if in-order? 'letrec* 'letrec) ,names ,gensyms ,(map unparse-tree-il vals) ,(unparse-tree-il body))) - (( names gensyms vals body) + (($ src names gensyms vals body) `(fix ,names ,gensyms ,(map unparse-tree-il vals) ,(unparse-tree-il body))) - (( exp body) + (($ src exp body) `(let-values ,(unparse-tree-il exp) ,(unparse-tree-il body))) - (( winder pre body post unwinder) + (($ src winder pre body post unwinder) `(dynwind ,(unparse-tree-il winder) ,(unparse-tree-il pre) ,(unparse-tree-il body) ,(unparse-tree-il post) ,(unparse-tree-il unwinder))) - (( fluids vals body) + (($ src fluids vals body) `(dynlet ,(map unparse-tree-il fluids) ,(map unparse-tree-il vals) ,(unparse-tree-il body))) - (( fluid) + (($ src fluid) `(dynref ,(unparse-tree-il fluid))) - (( fluid exp) + (($ src fluid exp) `(dynset ,(unparse-tree-il fluid) ,(unparse-tree-il exp))) - (( tag body handler) - `(prompt ,(unparse-tree-il tag) ,(unparse-tree-il body) ,(unparse-tree-il handler))) + (($ src tag body handler) + `(prompt ,(unparse-tree-il tag) + ,(unparse-tree-il body) + ,(unparse-tree-il handler))) - (( tag args tail) + (($ src tag args tail) `(abort ,(unparse-tree-il tag) ,(map unparse-tree-il args) ,(unparse-tree-il tail)))))