+ pefree(info, 1);
+ let_exp->data.callback->info = NULL;
+ }
+}
+
+static void psi_ffi_call(struct psi_call_frame *frame) {
+ struct psi_decl *decl = psi_call_frame_get_decl(frame);
+ struct psi_impl *impl = psi_call_frame_get_impl(frame);
+ struct psi_ffi_decl_info *decl_info = decl->info;
+ struct psi_ffi_impl_info *impl_info;
+ struct psi_call_frame *prev;
+
+ if (impl) {
+ impl_info = impl->info;
+ prev = impl_info->frame;
+ impl_info->frame = frame;
+ }
+ ffi_call(&decl_info->signature, FFI_FN(decl->sym),
+ psi_call_frame_get_rpointer(frame),
+ psi_call_frame_get_arg_pointers(frame));
+ if (impl) {
+ impl_info->frame = prev;
+ }
+}
+
+static void psi_ffi_call_va(struct psi_call_frame *frame) {
+ ffi_cif signature;
+ struct psi_call_frame *prev;
+ struct psi_decl *decl = psi_call_frame_get_decl(frame);
+ struct psi_impl *impl = psi_call_frame_get_impl(frame);
+ struct psi_ffi_decl_info *decl_info = decl->info;
+ struct psi_ffi_impl_info *impl_info;
+ size_t i, va_count, argc;
+ ffi_type **param_types;
+
+ argc = psi_plist_count(decl->args);
+ va_count = psi_call_frame_num_var_args(frame);
+ param_types = ecalloc(argc + va_count + 1, sizeof(ffi_type *));
+ memcpy(param_types, decl_info->params, argc * sizeof(ffi_type *));
+ for (i = 0; i < va_count; ++i) {
+ struct psi_call_frame_argument *frame_arg;
+
+ frame_arg = psi_call_frame_get_var_argument(frame, i);
+ param_types[argc + i] = psi_ffi_impl_type(frame_arg->va_type);
+ }
+
+ psi_ffi_prep_va(&decl_info->signature, &signature, argc, va_count, param_types);