mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-23 20:15:05 +02:00
Allow generated C files to compile
This commit is contained in:
parent
92e25a8640
commit
4b211430c4
2 changed files with 11 additions and 15 deletions
2
Makefile
2
Makefile
|
@ -42,7 +42,7 @@ test: $(TESTFILES) cyclone
|
|||
# A temporary testing directive
|
||||
.PHONY: test2
|
||||
test2: examples/hello-library/int-test/hello.c libcyclone.a
|
||||
# ./cyclone -t examples/hello-library/hello.scm
|
||||
./cyclone -t examples/hello-library/hello.scm
|
||||
# ./cyclone -t examples/hello-library/libs/lib2.sld
|
||||
# gcc examples/hello-library/int-test/lib2.c -I. -g -c -o lib2.o
|
||||
# gcc examples/hello-library/int-test/hello.c -L. -lcyclone -lm -I. -g -o hello
|
||||
|
|
24
cgen.scm
24
cgen.scm
|
@ -99,11 +99,6 @@
|
|||
(else
|
||||
(vector-set! *c-call-arity* arity #t))))
|
||||
|
||||
(define (emit-c-macros)
|
||||
(c-macro-declare-globals)
|
||||
(c-macro-GC-globals)
|
||||
(emit-c-arity-macros 0))
|
||||
|
||||
(define (emit-c-arity-macros arity)
|
||||
(when (<= arity *c-call-max-args*)
|
||||
(cond
|
||||
|
@ -172,25 +167,20 @@
|
|||
(define (c-macro-GC-globals)
|
||||
; emit directly to be more efficient
|
||||
; TODO: convert all c-macro functions to direct emit???
|
||||
(emit "#define GC_GLOBALS \\")
|
||||
(emits "{")
|
||||
(for-each
|
||||
(lambda (global)
|
||||
(emits " \\\n transp(")
|
||||
(emits "\n add_global((object *) &")
|
||||
(emits (mangle-global (car global)))
|
||||
(emits ");"))
|
||||
*globals*)
|
||||
(emit "}")
|
||||
(emit ""))
|
||||
|
||||
(define (c-macro-declare-globals)
|
||||
(emits "#define DECLARE_GLOBALS ")
|
||||
(for-each
|
||||
(lambda (global)
|
||||
(emit " \\")
|
||||
(emits " static volatile object ")
|
||||
(emits "object ")
|
||||
(emits (mangle-global (car global)))
|
||||
(emits " = nil;"))
|
||||
(emits " = nil;\n"))
|
||||
*globals*)
|
||||
(emit "")
|
||||
(emit ""))
|
||||
|
@ -945,8 +935,11 @@
|
|||
(if (member 'eval globals)
|
||||
(emit "#define CYC_EVAL"))
|
||||
|
||||
(emit-c-macros)
|
||||
(emit-c-arity-macros 0)
|
||||
(emit "#include \"cyclone.h\"")
|
||||
(c-macro-declare-globals)
|
||||
(emit "#include \"runtime.h\"")
|
||||
(emit "#include \"runtime-main.h\"")
|
||||
|
||||
;; Emit symbols
|
||||
(for-each
|
||||
|
@ -978,6 +971,9 @@
|
|||
(emit "
|
||||
static void c_entry_pt(argc, env,cont) int argc; closure env,cont; { ")
|
||||
|
||||
;; Initialize global table
|
||||
(c-macro-GC-globals)
|
||||
|
||||
;; Initialize symbol table
|
||||
(for-each
|
||||
(lambda (sym)
|
||||
|
|
Loading…
Add table
Reference in a new issue