}
-void PSI_ContextCall(PSI_Context *C, impl_val *ret_val, decl *decl)
+void PSI_ContextCall(PSI_Context *C, decl_callinfo *decl_call)
{
- C->ops->call(C, ret_val, decl);
+ C->ops->call(C, decl_call);
}
static inline void dump_decl_type(int fd, decl_type *t) {
void (*init)(PSI_Context *C);
void (*dtor)(PSI_Context *C);
zend_function_entry *(*compile)(PSI_Context *C);
- void (*call)(PSI_Context *C, impl_val *ret_val, decl *decl);
+ void (*call)(PSI_Context *C, decl *decl);
};
struct PSI_Context {
void PSI_ContextBuild(PSI_Context *C, const char *path);
int PSI_ContextValidate(PSI_Context *C, PSI_Parser *P);
zend_function_entry *PSI_ContextCompile(PSI_Context *C);
-void PSI_ContextCall(PSI_Context *C, impl_val *ret_val, decl *decl);
+void PSI_ContextCall(PSI_Context *C, decl_callinfo *decl_call);
void PSI_ContextDump(PSI_Context *C, int fd);
void PSI_ContextDtor(PSI_Context *C);
void PSI_ContextFree(PSI_Context **C);
call->params[c] = NULL;
decl->call.info = call;
+ decl->call.rval = decl->func->ptr;
+ decl->call.argc = c;
decl->call.args = (void **) &call->params[c+1];
rc = ffi_prep_cif(&call->signature, psi_ffi_abi(decl->abi->convention),
return zfe;
}
-static void psi_ffi_call(PSI_Context *C, impl_val *ret_val, decl *decl) {
- PSI_LibffiCall *call = decl->call.info;
+static void psi_ffi_call(PSI_Context *C, decl_callinfo *decl_call) {
+ PSI_LibffiCall *call = decl_call->info;
- ffi_call(&call->signature, FFI_FN(decl->call.sym), ret_val, decl->call.args);
+ ffi_call(&call->signature, FFI_FN(decl_call->sym), decl_call->rval, decl_call->args);
}
static PSI_ContextOps ops = {
call->params[c] = NULL;
decl->call.info = call;
+ decl->call.rval = decl->func->ptr;
+ decl->call.argc = c;
decl->call.args = (void **) &call->params[c+1];
call->signature = jit_type_create_signature(
return zfe;
}
-static void psi_jit_call(PSI_Context *C, impl_val *ret_val, decl *decl) {
- PSI_LibjitCall *call = decl->call.info;
+static void psi_jit_call(PSI_Context *C, decl_callinfo *decl_call) {
+ PSI_LibjitCall *call = decl_call->info;
- jit_apply(call->signature, decl->call.sym, decl->call.args,
- decl->args->count, ret_val);
+ jit_apply(call->signature, decl_call->sym, decl_call->args,
+ decl_call->argc, decl_call->rval);
}
static PSI_ContextOps ops = {
static inline void psi_do_free(free_stmt *fre)
{
size_t i, j;
- impl_val dummy;
for (i = 0; i < fre->calls->count; ++i) {
free_call *f = fre->calls->list[i];
}
/* FIXME: check in validate_* that free functions return scalar */
- PSI_ContextCall(&PSI_G(context), &dummy, f->decl);
+ PSI_ContextCall(&PSI_G(context), &f->decl->call);
}
}
impl->decl->call.args[i] = impl->decl->args->args[i]->let->ptr;
}
- PSI_ContextCall(&PSI_G(context), var->arg->ptr, impl->decl);
+ PSI_ContextCall(&PSI_G(context), &impl->decl->call);
psi_do_return(return_value, ret);
for (i = 0; i < impl->stmts->set.count; ++i) {
free(abi);
}
+typedef struct decl_callinfo {
+ void *sym;
+ void *info;
+ size_t argc;
+ void **args;
+ void *rval;
+} decl_callinfo;
+
typedef struct decl {
decl_abi *abi;
decl_arg *func;
decl_args *args;
struct impl *impl;
- struct {
- void *sym;
- void *info;
- void **args;
- } call;
+ decl_callinfo call;
} decl;
static inline decl* init_decl(decl_abi *abi, decl_arg *func, decl_args *args) {