mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-15 08:47:35 +02:00
unpack varargs
This commit is contained in:
parent
95f8a17124
commit
c77cfcd6f7
2 changed files with 19 additions and 26 deletions
|
@ -148,28 +148,21 @@ object Cyc_global_set_cps(void *thd, object cont, object sym, object * glo, obje
|
||||||
our compiler will compute the difference between the number of required
|
our compiler will compute the difference between the number of required
|
||||||
args and the number of provided ones, and pass the difference as 'count'
|
args and the number of provided ones, and pass the difference as 'count'
|
||||||
*/
|
*/
|
||||||
#define load_varargs(var, arg_var, count) \
|
#define load_varargs(var, args_var, start, count) \
|
||||||
list var = (count > 0) ? alloca(sizeof(pair_type)*count) : NULL; \
|
list var = ((count) > 0) ? alloca(sizeof(pair_type)*(count)) : NULL; \
|
||||||
{ \
|
{ \
|
||||||
int i; \
|
int i; \
|
||||||
object tmp; \
|
object tmp; \
|
||||||
va_list va; \
|
if ((count) > 0) { \
|
||||||
if (count > 0) { \
|
for (i = 0; i < (count); i++) { \
|
||||||
va_start(va, arg_var); \
|
tmp = arg[start + i]; \
|
||||||
for (i = 0; i < count; i++) { \
|
|
||||||
if (i) { \
|
|
||||||
tmp = va_arg(va, object); \
|
|
||||||
} else { \
|
|
||||||
tmp = arg_var; \
|
|
||||||
} \
|
|
||||||
var[i].hdr.mark = gc_color_red; \
|
var[i].hdr.mark = gc_color_red; \
|
||||||
var[i].hdr.grayed = 0; \
|
var[i].hdr.grayed = 0; \
|
||||||
var[i].hdr.immutable = 0; \
|
var[i].hdr.immutable = 0; \
|
||||||
var[i].tag = pair_tag; \
|
var[i].tag = pair_tag; \
|
||||||
var[i].pair_car = tmp; \
|
var[i].pair_car = tmp; \
|
||||||
var[i].pair_cdr = (i == (count-1)) ? NULL : &var[i + 1]; \
|
var[i].pair_cdr = (i == ((count)-1)) ? NULL : &var[i + 1]; \
|
||||||
} \
|
} \
|
||||||
va_end(va); \
|
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
/* Prototypes for primitive functions. */
|
/* Prototypes for primitive functions. */
|
||||||
|
|
|
@ -1868,19 +1868,19 @@
|
||||||
;; here if at all possible
|
;; here if at all possible
|
||||||
;;
|
;;
|
||||||
;; Load varargs from C stack into Scheme list
|
;; Load varargs from C stack into Scheme list
|
||||||
(string-append
|
(let ((num-fixargs (- (length (ast:lambda-formals->list exp))
|
||||||
;; DEBUGGING:
|
2 ;; include raw and "..."
|
||||||
;; "printf(\"%d %d\\n\", argc, "
|
(if has-closure? 1 0))))
|
||||||
;; (number->string (length (ast:lambda-formals->list exp))) ");"
|
(string-append
|
||||||
"load_varargs("
|
;; DEBUGGING:
|
||||||
(mangle (ast:lambda-varargs-var exp))
|
;; "printf(\"%d %d\\n\", argc, "
|
||||||
", "
|
;; (number->string (length (ast:lambda-formals->list exp))) ");"
|
||||||
(mangle (ast:lambda-varargs-var exp))
|
"load_varargs("
|
||||||
"_raw, argc - " (number->string
|
(mangle (ast:lambda-varargs-var exp))
|
||||||
(- (length (ast:lambda-formals->list exp))
|
", args"
|
||||||
1
|
", " (number->string num-fixargs)
|
||||||
(if has-closure? 1 0)))
|
", argc - " (number->string num-fixargs)
|
||||||
");\n");
|
");\n"))
|
||||||
"") ; No varargs, skip
|
"") ; No varargs, skip
|
||||||
(c:serialize
|
(c:serialize
|
||||||
(c:append
|
(c:append
|
||||||
|
|
Loading…
Add table
Reference in a new issue