mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-07 05:06:36 +02:00
Added cmd line option to autogen blocks of code
This commit is contained in:
parent
a4fcdf0e9e
commit
8e40505015
2 changed files with 18 additions and 11 deletions
27
cgen.scm
27
cgen.scm
|
@ -1048,10 +1048,11 @@
|
||||||
(emit "}")
|
(emit "}")
|
||||||
(emit *c-main-function*)))
|
(emit *c-main-function*)))
|
||||||
|
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Automatically generate blocks of code for the compiler
|
;; Automatically generate blocks of code for the compiler
|
||||||
;; TODO: need a compiler option to call this from cmd line
|
(define (autogen filename)
|
||||||
(define (autogen)
|
(let ((fp (open-output-file filename)))
|
||||||
(let ((fp (open-output-file "tmp.txt")))
|
|
||||||
(autogen:defprimitives fp)
|
(autogen:defprimitives fp)
|
||||||
(autogen:primitive-procedures fp)
|
(autogen:primitive-procedures fp)
|
||||||
(close-output-port fp)))
|
(close-output-port fp)))
|
||||||
|
@ -1071,13 +1072,17 @@
|
||||||
|
|
||||||
;; List of primitive procedures
|
;; List of primitive procedures
|
||||||
(define (autogen:primitive-procedures fp)
|
(define (autogen:primitive-procedures fp)
|
||||||
(pp ;; CHICKEN pretty-print
|
(let ((code
|
||||||
(cons
|
(cons
|
||||||
'list
|
'list
|
||||||
(map
|
(map
|
||||||
(lambda (p)
|
(lambda (p)
|
||||||
`(list (quote ,p) ,p))
|
`(list (quote ,p) ,p))
|
||||||
*primitives*))
|
*primitives*))))
|
||||||
fp))
|
(cond-expand
|
||||||
|
(chicken
|
||||||
|
(pp code fp)) ;; CHICKEN pretty-print
|
||||||
|
(else
|
||||||
|
(write code fp)))))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -158,6 +158,8 @@
|
||||||
(newline))
|
(newline))
|
||||||
((member "-v" args)
|
((member "-v" args)
|
||||||
(display *version-banner*))
|
(display *version-banner*))
|
||||||
|
((member "--autogen" args)
|
||||||
|
(autogen "autogen.out"))
|
||||||
((member "-d" args)
|
((member "-d" args)
|
||||||
(run-compiler args #f)) ;; Debug, do not run GCC
|
(run-compiler args #f)) ;; Debug, do not run GCC
|
||||||
(else
|
(else
|
||||||
|
|
Loading…
Add table
Reference in a new issue