1
0
forked from alex-eg/sex

generate temp .c files instead of passing to compiler's stdin

For a clearer architecture
This commit is contained in:
2026-09-14 23:53:21 +03:00
parent 1e435f7fdf
commit c709c69176

View File

@@ -123,20 +123,21 @@
(out-file (if (eq? output 'default) (out-file (if (eq? output 'default)
"a.out" "a.out"
output))) output)))
;; `process' hands back one record. Its port accessors are named ;; The generated C goes to a temporary .c file rather than the
;; from the *child's* point of view, so `process-input-port' is the ;; compiler's stdin
;; port we write to: the C compiler's stdin. (let ((c-file (create-temporary-file "c")))
(let* ((proc (process compiler (append (list "-o" out-file "-x" "c") (with-output-to-file c-file
(lambda () (emit-c sex-forms)))
(let ((proc (process compiler (append (list "-o" out-file)
(if (get-arg args 'compile-object #f) (if (get-arg args 'compile-object #f)
(list "-c") (list "-c")
(list)) (list))
(list "-") ; read stdin (list c-file)
cc-args))) cc-args))))
(cc-stdin (process-input-port proc))) (call-with-values (lambda () (process-wait proc))
(with-output-to-port cc-stdin (lambda status
(lambda () (emit-c sex-forms))) (delete-file* c-file)
(close-output-port cc-stdin) (apply values status)))))))
(process-wait proc))))
(define (semantic-process-forms raw-forms input-source) (define (semantic-process-forms raw-forms input-source)
(if (eq? input-source 'stdin) (if (eq? input-source 'stdin)