From: Michael Wallner Date: Wed, 11 Nov 2015 14:42:30 +0000 (+0100) Subject: flush X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=d9a7378b795f32b91e110bd163c019aa30e79084;p=m6w6%2Fext-psi flush --- diff --git a/src/context.c b/src/context.c index 83a1a28..35cedee 100644 --- a/src/context.c +++ b/src/context.c @@ -169,7 +169,7 @@ static inline int validate_decl_struct(PSI_Data *data, decl_struct *s) { return 0; } - ZEND_ASSERT(!darg->var->arg); + ZEND_ASSERT(!darg->var->arg || darg->var->arg == darg); darg->var->arg = darg; if (!darg->layout) { @@ -254,7 +254,9 @@ static inline int validate_decl(PSI_Data *data, void *dl, decl *decl) { } 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; @@ -280,6 +282,9 @@ static inline int validate_impl_ret_stmt(PSI_Data *data, impl *impl) { } 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); diff --git a/src/libffi.c b/src/libffi.c index 38fa096..e50ca0f 100644 --- a/src/libffi.c +++ b/src/libffi.c @@ -224,13 +224,13 @@ static void psi_ffi_handler(ffi_cif *_sig, void *_result, void **_args, void *_d 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); } } diff --git a/src/libjit.c b/src/libjit.c index 773f0e0..ee9b1f3 100644 --- a/src/libjit.c +++ b/src/libjit.c @@ -163,13 +163,13 @@ static void psi_jit_handler(jit_type_t _sig, void *result, void **_args, void *_ 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); } } diff --git a/src/module.c b/src/module.c index 6f152e3..a883e62 100644 --- a/src/module.c +++ b/src/module.c @@ -347,7 +347,7 @@ void psi_to_array(zval *return_value, token_t t, impl_val *ret_val, decl_var *va 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 */ @@ -547,9 +547,9 @@ void *psi_do_let(decl_arg *darg) } } -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); @@ -565,10 +565,8 @@ void psi_do_set(zval *return_value, set_func *func, decl_vars *vars) } } -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); diff --git a/src/parser.h b/src/parser.h index 3d2dd6f..84de6e8 100644 --- a/src/parser.h +++ b/src/parser.h @@ -590,6 +590,8 @@ static inline void free_set_func(set_func *func) { 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) { @@ -598,10 +600,21 @@ 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); } @@ -625,20 +638,21 @@ static inline void free_set_stmt(set_stmt *set) { } 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); } diff --git a/src/parser_proc.y b/src/parser_proc.y index 81a013c..a189a88 100644 --- a/src/parser_proc.y +++ b/src/parser_proc.y @@ -408,6 +408,19 @@ set_stmt(set) ::= SET impl_var(var) EQUALS set_value(val) EOS. { 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($$);} @@ -438,8 +451,8 @@ set_func(func) ::= VOID(T). { %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*}