mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-17 01:37:34 +02:00
WIP - alloca support for literals
This commit is contained in:
parent
765f6ffd8d
commit
ab4f9ee7a4
1 changed files with 13 additions and 11 deletions
|
@ -584,10 +584,13 @@
|
||||||
((null? exp)
|
((null? exp)
|
||||||
(c-code "NULL"))
|
(c-code "NULL"))
|
||||||
((pair? exp)
|
((pair? exp)
|
||||||
|
;; TODO: use-alloc support
|
||||||
(c-compile-scalars exp use-alloca))
|
(c-compile-scalars exp use-alloca))
|
||||||
((vector? exp)
|
((vector? exp)
|
||||||
|
;; TODO: use-alloc support
|
||||||
(c-compile-vector exp use-alloca))
|
(c-compile-vector exp use-alloca))
|
||||||
((bytevector? exp)
|
((bytevector? exp)
|
||||||
|
;; TODO: use-alloc support
|
||||||
(c-compile-bytevector exp use-alloca))
|
(c-compile-bytevector exp use-alloca))
|
||||||
((bignum? exp)
|
((bignum? exp)
|
||||||
(let ((cvar-name (mangle (gensym 'c)))
|
(let ((cvar-name (mangle (gensym 'c)))
|
||||||
|
@ -614,19 +617,15 @@
|
||||||
(number->string n)))))
|
(number->string n)))))
|
||||||
(rnum (num2str (real-part exp)))
|
(rnum (num2str (real-part exp)))
|
||||||
(inum (num2str (imag-part exp)))
|
(inum (num2str (imag-part exp)))
|
||||||
|
(addr-op (if use-alloca "" "&"))
|
||||||
|
(c-make-macro (if use-alloca "alloca_complex_num" "make_complex_num"))
|
||||||
)
|
)
|
||||||
(c-code/vars
|
(c-code/vars
|
||||||
(string-append "&" cvar-name) ; Code is just the variable name
|
(string-append addr-op cvar-name) ; Code is just the variable name
|
||||||
(list ; Allocate on the C stack
|
(list ; Allocate on the C stack
|
||||||
(string-append
|
(string-append
|
||||||
"make_complex_num(" cvar-name ", " rnum ", " inum ");")))))
|
c-make-macro "(" cvar-name ", " rnum ", " inum ");")))))
|
||||||
((integer? exp)
|
((integer? exp)
|
||||||
; (let ((cvar-name (mangle (gensym 'c))))
|
|
||||||
; (c-code/vars
|
|
||||||
; (string-append "&" cvar-name) ; Code is just the variable name
|
|
||||||
; (list ; Allocate integer on the C stack
|
|
||||||
; (string-append
|
|
||||||
; "make_int(" cvar-name ", " (number->string exp) ");")))))
|
|
||||||
(c-code (string-append "obj_int2obj("
|
(c-code (string-append "obj_int2obj("
|
||||||
(number->string exp) ")")))
|
(number->string exp) ")")))
|
||||||
((real? exp)
|
((real? exp)
|
||||||
|
@ -637,12 +636,15 @@
|
||||||
((nan? exp) "(0./0.)")
|
((nan? exp) "(0./0.)")
|
||||||
((infinite? exp) "(1./0.)")
|
((infinite? exp) "(1./0.)")
|
||||||
(else
|
(else
|
||||||
(number->string exp)))))
|
(number->string exp))))
|
||||||
|
(addr-op (if use-alloca "" "&"))
|
||||||
|
(c-make-macro (if use-alloca "alloca_double" "make_double"))
|
||||||
|
)
|
||||||
(c-code/vars
|
(c-code/vars
|
||||||
(string-append "&" cvar-name) ; Code is just the variable name
|
(string-append addr-op cvar-name) ; Code is just the variable name
|
||||||
(list ; Allocate on the C stack
|
(list ; Allocate on the C stack
|
||||||
(string-append
|
(string-append
|
||||||
"make_double(" cvar-name ", " num2str ");")))))
|
c-make-macro "(" cvar-name ", " num2str ");")))))
|
||||||
((boolean? exp)
|
((boolean? exp)
|
||||||
(c-code (string-append
|
(c-code (string-append
|
||||||
(if exp "boolean_t" "boolean_f"))))
|
(if exp "boolean_t" "boolean_f"))))
|
||||||
|
|
Loading…
Add table
Reference in a new issue