diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2020-03-12 18:53:44 -0400 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2020-03-12 18:53:44 -0400 |
commit | 1338c083d649ab15d4dee63a6f6d49e891f9cdfa (patch) | |
tree | 5a2610197820c7cd8c5e36e410e36ec82d298af7 /foreign.c | |
parent | 2da3e68e563fd5c17223183d6d89d442c873a1cb (diff) |
#foreign varargs
Diffstat (limited to 'foreign.c')
-rw-r--r-- | foreign.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -288,7 +288,8 @@ static void ffmgr_create(ForeignFnManager *ffmgr, Allocator *allocr) { str_hash_table_create(&ffmgr->libs_loaded, sizeof(Library), allocr); } -static bool foreign_call(ForeignFnManager *ffmgr, FnExpr *fn, Type *fn_type, Value *args, Location call_where, Value *ret) { +/* args must be a dynamic array. */ +static bool foreign_call(ForeignFnManager *ffmgr, FnExpr *fn, Type *ret_type, Type *arg_types, size_t arg_types_stride, Value *args, size_t nargs, Location call_where, Value *ret) { void (*fn_ptr)() = fn->foreign.fn_ptr; if (!fn_ptr) { assert(fn->flags & FN_EXPR_FOREIGN); @@ -326,16 +327,15 @@ static bool foreign_call(ForeignFnManager *ffmgr, FnExpr *fn, Type *fn_type, Val } av_alist arg_list; - if (!arg_list_start(&arg_list, fn_ptr, ret, &fn_type->fn.types[0], call_where)) + if (!arg_list_start(&arg_list, fn_ptr, ret, ret_type, call_where)) return false; - size_t nparams = arr_len(fn_type->fn.types)-1; - for (size_t i = 0; i < nparams; ++i) { - if (!arg_list_add(&arg_list, args[i], &fn_type->fn.types[i+1], call_where)) + char *type = (char *)arg_types; + for (size_t i = 0; i < nargs; ++i) { + if (!arg_list_add(&arg_list, args[i], (Type *)type, call_where)) return false; + type += arg_types_stride; } av_call(arg_list); - - (void)fn_type; (void)args; return true; } |