mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-21 22:59:16 +02:00
Use for-each to call c-compile-program
Use for-each instead of map as this guarantees execution order. Which is important since c-compile-program has side-effects.
This commit is contained in:
parent
6569106c1a
commit
b7c11fc8ed
1 changed files with 14 additions and 3 deletions
17
cgen.scm
17
cgen.scm
|
@ -991,9 +991,20 @@
|
|||
globals
|
||||
required-libs)
|
||||
(set! *global-syms* (append globals imported-globals))
|
||||
(let ((compiled-program
|
||||
(apply string-append
|
||||
(map c-compile-program input-program))))
|
||||
(let ((compiled-program-lst '())
|
||||
(compiled-program #f))
|
||||
;; Compile program, using for-each to guarantee execution order,
|
||||
;; since c-compile-program has side-effects.
|
||||
(for-each
|
||||
(lambda (expr)
|
||||
(set! compiled-program-lst
|
||||
(cons (c-compile-program expr) compiled-program-lst)))
|
||||
input-program)
|
||||
|
||||
;; Get top-level string
|
||||
(set! compiled-program
|
||||
(apply string-append (reverse compiled-program-lst)))
|
||||
|
||||
(emit-c-arity-macros 0)
|
||||
(emit "#include \"cyclone.h\"")
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue