return 0;
}
- ZEND_ASSERT(!darg->var->arg);
+ ZEND_ASSERT(!darg->var->arg || darg->var->arg == darg);
darg->var->arg = darg;
if (!darg->layout) {
}
return 1;
}
-
+static inline int validate_set_value(PSI_Data *data, set_value *set) {
+ set->
+}
static inline decl *locate_impl_decl(decls *decls, return_stmt *ret) {
size_t i;
}
return 0;
}
+ if (!validate_impl_set_value(data, impl->stmts->ret.list[0]->set)) {
+ return 0;
+ }
if (!(impl->decl = locate_impl_decl(data->decls, impl->stmts->ret.list[0]))) {
data->error(PSI_WARNING, "Missing declaration for implementation %s",
impl->func->name);
ffi_call(&data->signature, FFI_FN(data->impl->decl->dlptr), &ret_val, arg_prm);
- psi_do_return(data->impl, &ret_val, *(zval **)_args[1]);
+ psi_do_return(data->impl->stmts->ret.list[0], &ret_val, *(zval **)_args[1]);
for (i = 0; i < data->impl->stmts->set.count; ++i) {
set_stmt *set = data->impl->stmts->set.list[i];
if (set->arg->_zv) {
- psi_do_set(set->arg->_zv, set->val->func, set->val->vars);
+ psi_do_set(set->arg->_zv, set->val);
}
}
jit_apply(data->signature, data->impl->decl->dlptr, arg_prm, data->impl->decl->args->count, &ret_val);
- psi_do_return(data->impl, &ret_val, *(zval **)_args[1]);
+ psi_do_return(data->impl->stmts->ret.list[0], &ret_val, *(zval **)_args[1]);
for (i = 0; i < data->impl->stmts->set.count; ++i) {
set_stmt *set = data->impl->stmts->set.list[i];
if (set->arg->_zv) {
- psi_do_set(set->arg->_zv, set->val->func, set->val->vars);
+ psi_do_set(set->arg->_zv, set->val);
}
}
case PSI_T_INT8:
case PSI_T_UINT8:
if (darg->var->pointer_level) {
- psi_to_string(&ztmp, real_decl_type(darg->type)->type, &tmp, darg->var);
+ psi_to_string(&ztmp, real_decl_type(darg->type)->type, &tmp_ptr, darg->var);
break;
}
/* no break */
}
}
-void psi_do_set(zval *return_value, set_func *func, decl_vars *vars)
+void psi_do_set(zval *return_value, set_value *set)
{
- impl_val *val = (impl_val *) &vars->vars[0]->arg->let->ptr;
+ impl_val *val = (impl_val *) &set->vars->vars[0]->arg->let->ptr;
ZVAL_DEREF(return_value);
zval_dtor(return_value);
}
}
-void psi_do_return(impl *impl, impl_val *ret_val, zval *return_value)
+void psi_do_return(return_stmt *ret, impl_val *ret_val, zval *return_value)
{
- return_stmt *ret = impl->stmts->ret.list[0];
-
switch (ret->func->type) {
case PSI_T_TO_STRING:
psi_to_string(return_value, real_decl_type(impl->decl->func->type)->type, ret_val, ret->decl);
typedef struct set_value {
set_func *func;
decl_vars *vars;
+ struct set_value **inner;
+ size_t count;
} set_value;
static inline set_value *init_set_value(set_func *func, decl_vars *vars) {
val->vars = vars;
return val;
}
+static inline set_value *add_inner_set_value(set_value *val, set_value *inner) {
+ val->inner = realloc(val->inner, ++val->count * sizeof(*val->inner));
+ val->inner[val->count-1] = inner;
+ return val;
+}
static inline void free_set_value(set_value *val) {
free_set_func(val->func);
free_decl_vars(val->vars);
+ if (val->inner) {
+ size_t i;
+ for (i = 0; i < val->count; ++i) {
+ free_set_value(val->inner[i]);
+ }
+ }
free(val);
}
}
typedef struct return_stmt {
- set_func *func;
+ set_value *set;
decl_var *decl;
} return_stmt;
-static inline return_stmt *init_return_stmt(set_func *func, decl_var *decl) {
+static inline return_stmt *init_return_stmt(set_value *val) {
return_stmt *ret = calloc(1, sizeof(*ret));
- ret->func = func;
- ret->decl = decl;
+ ret->set = val;
+ ret->decl = val->vars->vars[0];
return ret;
}
static inline void free_return_stmt(return_stmt *ret) {
- free_set_func(ret->func);
- free_decl_var(ret->decl);
+ //free_set_func(ret->func);
+ //free_decl_var(ret->decl);
+ free_set_value(ret->set);
free(ret);
}
set_value(val) ::= set_func(func) LPAREN decl_vars(vars) RPAREN. {
val = init_set_value(func, vars);
}
+set_value(val) ::= set_func(func_) LPAREN decl_vars(vars_) COMMA set_vals(vals) RPAREN. {
+ val = vals;
+ val->func = func_;
+ val->vars = vars_;
+}
+%type set_vals {set_value*}
+%destructor set_vals {free_set_value($$);}
+set_vals(vals) ::= set_value(val). {
+ vals = add_inner_set_value(init_set_value(NULL, NULL), val);
+}
+set_vals(vals) ::= set_vals(vals_) COMMA set_value(val). {
+ vals = add_inner_set_value(vals_, val);
+}
%type set_func {set_func*}
%destructor set_func {free_set_func($$);}
%type return_stmt {return_stmt*}
%destructor return_stmt {free_return_stmt($$);}
-return_stmt(ret) ::= RETURN set_func(func) LPAREN decl_var(var) RPAREN EOS. {
- ret = init_return_stmt(func, var);
+return_stmt(ret) ::= RETURN set_value(val) EOS. {
+ ret = init_return_stmt(val);
}
%type free_stmt {free_stmt*}