Prevent "too many arguments" errors

Use folds instead of apply to prevent errors with too many arguments passed.
This commit is contained in:
Justin Ethier 2016-03-01 22:09:26 -05:00
parent 9720387420
commit abdce5d978

View file

@ -222,25 +222,26 @@
(define (c:num-args c-tuple) (caddr c-tuple)) (define (c:num-args c-tuple) (caddr c-tuple))
(define (c:allocs->str c-allocs . prefix) (define (c:allocs->str c-allocs . prefix)
(apply (foldr
string-append (lambda (x y)
(map (string-append
(lambda (c) (string-append
(string-append
(if (null? prefix) (if (null? prefix)
"" ""
(car prefix)) (car prefix))
c x
"\n")) "\n")
c-allocs))) y))
""
c-allocs))
(define (c:allocs->str2 c-allocs prefix suffix) (define (c:allocs->str2 c-allocs prefix suffix)
(apply (foldr
string-append (lambda (x y)
(map (string-append
(lambda (c) (string-append prefix x suffix)))
(string-append prefix c suffix)) ""
c-allocs))) c-allocs))
(define (c:append cp1 cp2) (define (c:append cp1 cp2)
(c-code/vars (c-code/vars
@ -1280,7 +1281,7 @@
;; Get top-level string ;; Get top-level string
(set! compiled-program (set! compiled-program
(apply string-append (reverse compiled-program-lst))) (foldr string-append "" (reverse compiled-program-lst)))
(emit-c-arity-macros 0) (emit-c-arity-macros 0)
(emit "#include \"cyclone/types.h\"") (emit "#include \"cyclone/types.h\"")