Code generation improvements #7

Merged
alex-eg merged 9 commits from generate-c89-code into main 2025-08-22 14:47:36 +02:00
Showing only changes of commit 176844171c - Show all commits

View File

@@ -15,7 +15,6 @@
(define (fmt-macro-params st) (fmt-ref st 'macro-params)) (define (fmt-macro-params st) (fmt-ref st 'macro-params))
(define (fmt-expression? st) (fmt-ref st 'expression?)) (define (fmt-expression? st) (fmt-ref st 'expression?))
(define (fmt-return? st) (fmt-ref st 'return?)) (define (fmt-return? st) (fmt-ref st 'return?))
(define (fmt-default-type st) (fmt-ref st 'default-type 'int))
(define (fmt-newline-before-brace? st) (fmt-ref st 'newline-before-brace?)) (define (fmt-newline-before-brace? st) (fmt-ref st 'newline-before-brace?))
(define (fmt-braceless-bodies? st) (fmt-ref st 'braceless-bodies?)) (define (fmt-braceless-bodies? st) (fmt-ref st 'braceless-bodies?))
(define (fmt-non-spaced-ops? st) (fmt-ref st 'non-spaced-ops?)) (define (fmt-non-spaced-ops? st) (fmt-ref st 'non-spaced-ops?))
@@ -608,7 +607,7 @@
(cond (cond
((procedure? x) x) ((procedure? x) x)
((pair? x) (c-type (car x) (cadr x))) ((pair? x) (c-type (car x) (cadr x)))
(else (cat (lambda (st) ((c-type (fmt-default-type st)) st)) " " x)))) (else (error "missing type" x))))
(define (c-field x) (define (c-field x)
(cond (cond
@@ -624,7 +623,7 @@
(else (c-type (car x) (cadr x)))) (else (c-type (car x) (cadr x))))
(c-type (car x) (c-type (car x)
(fmt-join c-expr (cdr x) ", ")))) (fmt-join c-expr (cdr x) ", "))))
(else (cat (lambda (st) ((c-type (fmt-default-type st)) st)) " " x)))) (else (error "missing type" x))))
(define (c-param-list ls) (define (c-param-list ls)
(c-in-expr (fmt-join/dot c-param (lambda (dot) (dsp "...")) ls ", "))) (c-in-expr (fmt-join/dot c-param (lambda (dot) (dsp "...")) ls ", ")))