From 55a9ceb549911e598be213bdb755272e0f9c4a5c Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Tue, 23 Aug 2022 19:24:26 -0700 Subject: Change argument passing to use lists. Using vectors is just horribly complicated combined with builtins like apply, or procedures that take a rest parameter. Now we pass all arguments in a list. Hopefully optimization can undo this for known functions in the future. --- lib/csc/macros-test.csc | 37 +++++++++++-------------------------- 1 file changed, 11 insertions(+), 26 deletions(-) (limited to 'lib/csc/macros-test.csc') diff --git a/lib/csc/macros-test.csc b/lib/csc/macros-test.csc index be573cb..ee4e295 100644 --- a/lib/csc/macros-test.csc +++ b/lib/csc/macros-test.csc @@ -242,12 +242,12 @@ (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)))))) + (make-lambda (test-ref 'args) (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 ...) + ((define (f) body ...) (builtin-define f (lambda args body ...))))) (define (exit) (call-builtin exit code)))) @@ -259,40 +259,25 @@ (make-lexical-ref sym (gensym))) - (test builtin-lambda-rest - (assert-equal - (make-lambda (list - (test-ref 'a) - (test-ref 'b) - (test-ref 'c)) - (test-ref 'd) - (make-sequence (make-constant #f) (make-constant 5))) - (expand-body 'main - '((lambda - (a b c . d) (quote 5))) - builtins-environment) - transform-ir1)) - - (test builtin-lambda-ref (assert-equal - (make-lambda (list (test-ref 'x)) #f - (make-sequence (make-constant #f) (test-ref 'x))) + (make-lambda (test-ref 'args) + (make-sequence (make-constant #f) (test-ref 'args))) (expand-body 'main - '((lambda (x) x)) + '((lambda args args)) builtins-environment) transform-ir1)) (test builtin-case-lambda-defines (assert-equal - (make-lambda (list (test-ref 'x)) #f + (make-lambda (test-ref 'args) (make-letrec #t '(a b) (list (gensym) (gensym)) (list (make-constant 6) (test-ref 'a)) (make-sequence (make-constant #f) (make-constant 7)))) (expand-body 'main - '((lambda (x) + '((lambda args (builtin-define a (quote 6)) (builtin-define b a) (quote 7))) @@ -325,13 +310,13 @@ (test builtin-lexical-set (assert-equal - (make-lambda (list (test-ref 'x)) #f + (make-lambda (test-ref 'args) (make-sequence (make-constant #f) - (make-lexical-set (test-ref 'x) (make-constant 5)))) + (make-lexical-set (test-ref 'args) (make-constant 5)))) (expand-body 'main - '((lambda (x) - (set! x 5))) + '((lambda args + (set! args 5))) builtins-environment) transform-ir1)) -- cgit v1.3.1