Added cmd line option to autogen blocks of code

This commit is contained in:
Justin Ethier 2015-02-24 12:54:05 -05:00
parent a4fcdf0e9e
commit 8e40505015
2 changed files with 18 additions and 11 deletions

View file

@ -1048,10 +1048,11 @@
(emit "}")
(emit *c-main-function*)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Automatically generate blocks of code for the compiler
;; TODO: need a compiler option to call this from cmd line
(define (autogen)
(let ((fp (open-output-file "tmp.txt")))
(define (autogen filename)
(let ((fp (open-output-file filename)))
(autogen:defprimitives fp)
(autogen:primitive-procedures fp)
(close-output-port fp)))
@ -1071,13 +1072,17 @@
;; List of primitive procedures
(define (autogen:primitive-procedures fp)
(pp ;; CHICKEN pretty-print
(cons
'list
(map
(lambda (p)
`(list (quote ,p) ,p))
*primitives*))
fp))
(let ((code
(cons
'list
(map
(lambda (p)
`(list (quote ,p) ,p))
*primitives*))))
(cond-expand
(chicken
(pp code fp)) ;; CHICKEN pretty-print
(else
(write code fp)))))

View file

@ -158,6 +158,8 @@
(newline))
((member "-v" args)
(display *version-banner*))
((member "--autogen" args)
(autogen "autogen.out"))
((member "-d" args)
(run-compiler args #f)) ;; Debug, do not run GCC
(else