mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-09 22:17:33 +02:00
Require num_args for primitive_type
This will allow us to use the same validation code as for closures.
This commit is contained in:
parent
a05959cb90
commit
8526a0676f
2 changed files with 5 additions and 8 deletions
|
@ -1471,6 +1471,7 @@ typedef struct {
|
|||
gc_header_type hdr;
|
||||
tag_type tag;
|
||||
function_type fn;
|
||||
int num_args;
|
||||
const char *desc;
|
||||
} primitive_type;
|
||||
typedef primitive_type *primitive;
|
||||
|
|
12
runtime.c
12
runtime.c
|
@ -5794,27 +5794,23 @@ object apply(void *data, object cont, object func, object args)
|
|||
|
||||
switch (type_of(func)) {
|
||||
case primitive_tag:
|
||||
TODO: fn function signature changed, need to convert from list to array
|
||||
((primitive_type *) func)->fn(data, cont, args);
|
||||
break;
|
||||
case macro_tag:
|
||||
case closure0_tag:
|
||||
case closure1_tag:
|
||||
case closureN_tag:
|
||||
count = Cyc_length(data, args);
|
||||
if (func == Cyc_glo_call_cc) {
|
||||
// make_pair(c, cont, args);
|
||||
//Cyc_display(data, args, stderr);
|
||||
// args = &c;
|
||||
//Cyc_display(data, &c, stderr);
|
||||
count = Cyc_length(data, args);
|
||||
Cyc_check_num_args(data, "<procedure>", 1, args);
|
||||
dispatch(data, obj_obj2int(count), ((closure) func)->fn, func, cont,
|
||||
args);
|
||||
} else {
|
||||
Cyc_check_num_args(data, "<procedure>", ((closure) func)->num_args, args); // TODO: could be more efficient, eg: cyc_length(args) is called twice.
|
||||
dispatch(data, obj_obj2int(count), ((closure) func)->fn, func, cont, args);
|
||||
}
|
||||
count = Cyc_length(data, args);
|
||||
// TODO: validate number of args provided:
|
||||
Cyc_check_num_args(data, "<procedure>", ((closure) func)->num_args, args); // TODO: could be more efficient, eg: cyc_length(args) is called twice.
|
||||
dispatch(data, obj_obj2int(count), ((closure) func)->fn, func, cont, args);
|
||||
break;
|
||||
|
||||
case pair_tag:
|
||||
|
|
Loading…
Add table
Reference in a new issue