fix tree-il test to work if source info happens to be present
authorAndy Wingo <wingo@pobox.com>
Fri, 22 May 2009 11:00:23 +0000 (13:00 +0200)
committerAndy Wingo <wingo@pobox.com>
Fri, 22 May 2009 11:00:23 +0000 (13:00 +0200)
* module/language/tree-il/compile-glil.scm (flatten-lambda): Fix source
  emission.

* test-suite/tests/tree-il.test (strip-source): Strip source info on
  tree-il before compiling, so we don't get extraneous source info in the
  glil. Make check passes!

module/language/tree-il/compile-glil.scm
test-suite/tests/tree-il.test

index 1bd6587..94ace7e 100644 (file)
           ;; write bindings and source debugging info
           (emit-bindings #f ids vars allocation emit-code)
           (if (lambda-src x)
-              (emit-code (make-glil-source (lambda-src x))))
+              (emit-code #f (make-glil-source (lambda-src x))))
 
           ;; copy args to the heap if necessary
           (let lp ((in vars) (n 0))
index eb33ae7..18b67d6 100644 (file)
   #:use-module (language tree-il)
   #:use-module (language glil))
 
+;; Of course, the GLIL that is emitted depends on the source info of the
+;; input. Here we're not concerned about that, so we strip source
+;; information from the incoming tree-il.
+
+(define (strip-source x)
+  (post-order! (lambda (x) (set! (tree-il-src x) #f))
+               x))
+
 (define-syntax assert-scheme->glil
   (syntax-rules ()
     ((_ in out)
-     (let ((tree-il (compile 'in #:from 'scheme #:to 'tree-il)))
+     (let ((tree-il (strip-source
+                     (compile 'in #:from 'scheme #:to 'tree-il))))
        (pass-if 'in
                 (equal? (unparse-glil (compile tree-il #:from 'tree-il #:to 'glil))
                         'out))))))
@@ -36,7 +45,7 @@
   (syntax-rules ()
     ((_ in out)
      (pass-if 'in
-              (let ((tree-il (parse-tree-il 'in)))
+              (let ((tree-il (strip-source (parse-tree-il 'in))))
                 (equal? (unparse-glil (compile tree-il #:from 'tree-il #:to 'glil))
                         'out))))))
 
      (let ((exp 'in))
        (pass-if 'in
          (let ((glil (unparse-glil
-                      (compile (parse-tree-il exp)
+                      (compile (strip-source (parse-tree-il exp))
                                #:from 'tree-il #:to 'glil))))
            (pmatch glil
              (pat (guard test ...) #t)
              (else #f))))))))
 
-
 (with-test-prefix "void"
   (assert-tree-il->glil
    (void)