mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-13 07:47:39 +02:00
Refactoring, stage new arg to c-compile-const
New signature is: (c-compile-const exp use-alloca immutable) This will allow the compilation of immutable objects.
This commit is contained in:
parent
ba569882ea
commit
daa8f92f0c
1 changed files with 9 additions and 5 deletions
|
@ -425,7 +425,7 @@
|
||||||
(string-append cvar ".hdr.immutable = 1;"))
|
(string-append cvar ".hdr.immutable = 1;"))
|
||||||
(else ""))) ;; Mutable (default), no need to set anything
|
(else ""))) ;; Mutable (default), no need to set anything
|
||||||
|
|
||||||
(define (c-compile-scalars args use-alloca quoted)
|
(define (c-compile-scalars args use-alloca immutable)
|
||||||
(letrec (
|
(letrec (
|
||||||
(addr-op (if use-alloca "" "&"))
|
(addr-op (if use-alloca "" "&"))
|
||||||
;; (deref-op (if use-alloca "->" "."))
|
;; (deref-op (if use-alloca "->" "."))
|
||||||
|
@ -436,7 +436,7 @@
|
||||||
(c-code/vars
|
(c-code/vars
|
||||||
(string-append
|
(string-append
|
||||||
c-make-macro "(" cvar "," (c:body a) "," (c:body b) ");"
|
c-make-macro "(" cvar "," (c:body a) "," (c:body b) ");"
|
||||||
(c-set-immutable-field cvar use-alloca quoted))
|
(c-set-immutable-field cvar use-alloca immutable))
|
||||||
(append (c:allocs a) (c:allocs b)))))
|
(append (c:allocs a) (c:allocs b)))))
|
||||||
(_c-compile-scalars
|
(_c-compile-scalars
|
||||||
(lambda (args)
|
(lambda (args)
|
||||||
|
@ -449,7 +449,7 @@
|
||||||
(let* ((cvar-name (mangle (gensym 'c)))
|
(let* ((cvar-name (mangle (gensym 'c)))
|
||||||
(cell (create-cons
|
(cell (create-cons
|
||||||
cvar-name
|
cvar-name
|
||||||
(c-compile-const (car args) use-alloca)
|
(c-compile-const (car args) use-alloca immutable)
|
||||||
(_c-compile-scalars (cdr args)))))
|
(_c-compile-scalars (cdr args)))))
|
||||||
(set! num-args (+ 1 num-args))
|
(set! num-args (+ 1 num-args))
|
||||||
(c-code/vars
|
(c-code/vars
|
||||||
|
@ -599,12 +599,16 @@
|
||||||
;; Typically this function is used to compile constant values such as
|
;; Typically this function is used to compile constant values such as
|
||||||
;; a single number, boolean, etc. However, it can be passed a quoted
|
;; a single number, boolean, etc. However, it can be passed a quoted
|
||||||
;; item such as a list, to compile as a literal.
|
;; item such as a list, to compile as a literal.
|
||||||
(define (c-compile-const exp use-alloca)
|
;;
|
||||||
|
;; exp - Expression to compile
|
||||||
|
;; use-alloca - Should C objects be dynamically allocated on the stack?
|
||||||
|
;; immutable - Should C object be flagged as immutable?
|
||||||
|
(define (c-compile-const exp use-alloca immutable)
|
||||||
(cond
|
(cond
|
||||||
((null? exp)
|
((null? exp)
|
||||||
(c-code "NULL"))
|
(c-code "NULL"))
|
||||||
((pair? exp)
|
((pair? exp)
|
||||||
(c-compile-scalars exp use-alloca #f)) ;; TODO: quoted should be an input param
|
(c-compile-scalars exp use-alloca immutable))
|
||||||
((vector? exp)
|
((vector? exp)
|
||||||
(c-compile-vector exp use-alloca))
|
(c-compile-vector exp use-alloca))
|
||||||
((bytevector? exp)
|
((bytevector? exp)
|
||||||
|
|
Loading…
Add table
Reference in a new issue