From d4bd262329827738d08a431f9556fbe6fa8d5a80 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Fri, 12 Aug 2022 16:59:42 -0700 Subject: Fix bugs in the macro expander. Now I'm following the rule that you should ignore marks that were added after the binding was defined. I also introduced a lexical environment to handle lambdas. --- lib/csc/macros-test.csc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'lib/csc/macros-test.csc') diff --git a/lib/csc/macros-test.csc b/lib/csc/macros-test.csc index 9b4c128..be573cb 100644 --- a/lib/csc/macros-test.csc +++ b/lib/csc/macros-test.csc @@ -37,6 +37,7 @@ make-letrec make-lexical-ref make-lexical-set + make-library-define make-library-ref make-sequence sequence?) @@ -238,6 +239,22 @@ transform-ir1)) + (test builtin-syntax-rules-define + (assert-equal + (make-library-define (make-library-ref 'exit 'main) + (make-lambda '() #f (make-sequence (make-constant #f) (make-call-builtin 'exit (list (make-library-ref 'code 'main)))))) + (expand-body 'main + '((let-syntax + (define + (syntax-rules () + ((define (f . args) body ...) + (builtin-define f (lambda args body ...))))) + (define (exit) + (call-builtin exit code)))) + builtins-environment) + transform-ir1)) + + (define (test-ref sym) (make-lexical-ref sym (gensym))) @@ -257,6 +274,16 @@ transform-ir1)) + (test builtin-lambda-ref + (assert-equal + (make-lambda (list (test-ref 'x)) #f + (make-sequence (make-constant #f) (test-ref 'x))) + (expand-body 'main + '((lambda (x) x)) + builtins-environment) + transform-ir1)) + + (test builtin-case-lambda-defines (assert-equal (make-lambda (list (test-ref 'x)) #f -- cgit v1.3.1