Added stubs for compiling/evaluating vectors

This commit is contained in:
Justin Ethier 2015-06-03 23:00:40 -04:00
parent 935226740e
commit bc01c9dd19
4 changed files with 19 additions and 0 deletions

View file

@ -316,6 +316,15 @@
(_c-compile-scalars args)
num-args)))
(define (c-compile-vector exp)
;; TODO: this is just a stub, does not allocate vector contents
(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_empty_vector(" cvar-name ");")))))
;; c-compile-const : const-exp -> c-pair
;;
;; Typically this function is used to compile constant values such as
@ -327,6 +336,8 @@
(c-code "nil"))
((pair? exp)
(c-compile-scalars exp))
((vector? exp)
(c-compile-vector exp))
((integer? exp)
(let ((cvar-name (mangle (gensym 'c))))
(c-code/vars

View file

@ -176,6 +176,8 @@ typedef struct {tag_type tag; FILE *fp; int mode;} port_type;
typedef struct {tag_type tag; int num_elt; object *elts;} vector_type;
typedef vector_type *vector;
#define make_empty_vector(v) vector_type v; v.tag = vector_tag; v.num_elt = 0; v.elts = NULL;
/* Define cons type. */
typedef struct {tag_type tag; object cons_car,cons_cdr;} cons_type;

View file

@ -8,3 +8,8 @@
(write (make-vector 4 #t))
(write (string->list "abc"))
(write (apply append '((1) (2) (3))))
(write #(a))
(write #(1 2 3))
(write #((1) (2) (3)))
(write '#(1))
(write '#())

View file

@ -295,6 +295,7 @@
(or (integer? exp)
(real? exp)
(string? exp)
(vector? exp)
(char? exp)
(boolean? exp)))