mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-19 05:39:17 +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 *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)))))
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue