mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-25 04:55:04 +02:00
WIP
This commit is contained in:
parent
b2cc35e141
commit
d9add7ab54
2 changed files with 15 additions and 3 deletions
7
cgen.scm
7
cgen.scm
|
@ -351,6 +351,13 @@
|
||||||
(c-code "nil"))
|
(c-code "nil"))
|
||||||
((pair? exp)
|
((pair? exp)
|
||||||
(c-compile-scalars exp))
|
(c-compile-scalars exp))
|
||||||
|
((real? exp)
|
||||||
|
(let ((cvar-name (mangle (gensym 'c))))
|
||||||
|
(c-code/vars
|
||||||
|
(string-append "&" cvar-name) ; Code is just the variable name
|
||||||
|
(list ; Allocate on the C stack
|
||||||
|
(string-append
|
||||||
|
"make_double(" cvar-name ", " (number->string exp) ");")))))
|
||||||
((integer? exp)
|
((integer? exp)
|
||||||
(let ((cvar-name (mangle (gensym 'c))))
|
(let ((cvar-name (mangle (gensym 'c))))
|
||||||
(c-code/vars
|
(c-code/vars
|
||||||
|
|
11
runtime.h
11
runtime.h
|
@ -615,9 +615,14 @@ static integer_type Cyc_length(object l){
|
||||||
|
|
||||||
static string_type Cyc_number2string(object n) {
|
static string_type Cyc_number2string(object n) {
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
int num = ((integer_type *) n)->value;
|
snprintf(buffer, 1024, "%d", ((integer_type *)n)->value);
|
||||||
|
//TODO: if (type_of(n) == integer_tag) {
|
||||||
snprintf(buffer, 1024, "%d", num);
|
//TODO: snprintf(buffer, 1024, "%d", ((integer_type *)n)->value);
|
||||||
|
//TODO: } else if (type_of(n) == double_tag) {
|
||||||
|
//TODO: snprintf(buffer, 1024, "%lf", ((double_type *)n)->value);
|
||||||
|
//TODO: } else {
|
||||||
|
//TODO: buffer[0] = '\0'; // TODO: throw error instead
|
||||||
|
//TODO: }
|
||||||
make_string(str, buffer);
|
make_string(str, buffer);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue