X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Ftypes%2Freturn_exp.c;h=375f096982568e151fe0b744a9c0ed7df84905fa;hb=c0873cbbe9e5a83305adbc2bbd94aede5437f33d;hp=8718ecfc3877ba7b06a7616edd73ab6140f3d419;hpb=b78637d9020222f1032349f231c0dc84a69797bc;p=m6w6%2Fext-psi diff --git a/src/types/return_exp.c b/src/types/return_exp.c index 8718ecf..375f096 100644 --- a/src/types/return_exp.c +++ b/src/types/return_exp.c @@ -45,9 +45,7 @@ void psi_return_exp_free(struct psi_return_exp **exp_ptr) struct psi_return_exp *exp = *exp_ptr; *exp_ptr = NULL; - if (exp->token) { - psi_token_free(&exp->token); - } + psi_token_free(&exp->token); if (exp->func) { psi_decl_var_free(&exp->func); } @@ -108,9 +106,9 @@ static inline bool psi_return_exp_validate_decl_args(struct psi_data *data, if (exp->args) { if (psi_plist_count(exp->args) != psi_plist_count(impl->decl->args)) { data->error(data, exp->token, PSI_WARNING, - "Argument count of return statement of implementation '%s'" + "Argument count of return statement of implementation '%s' " "does not match argument count of declaration '%s'", - impl->func->name, impl->decl->func->var->name); + impl->func->name->val, impl->decl->func->var->name->val); return false; } @@ -122,27 +120,35 @@ static inline bool psi_return_exp_validate_decl_args(struct psi_data *data, } bool psi_return_exp_validate(struct psi_data *data, struct psi_return_exp *exp, - struct psi_impl *impl) + struct psi_validate_scope *scope) { size_t i = 0; struct psi_decl *decl; - const char *name = psi_return_exp_get_decl_name(exp); + zend_string *name = psi_return_exp_get_decl_name(exp); + while (psi_plist_get(data->decls, i++, &decl)) { - if (!strcmp(decl->func->var->name, name)) { - impl->decl = decl; - return psi_return_exp_validate_decl_args(data, exp, impl) && - psi_set_exp_validate(data, exp->set, impl, NULL); + if (zend_string_equals(decl->func->var->name, name)) { + scope->impl->decl = decl; + if (psi_return_exp_validate_decl_args(data, exp, scope->impl)) { + scope->current_set = exp->set; + if (psi_set_exp_validate(data, exp->set, scope)) { + scope->current_set = NULL; + return true; + } + scope->current_set = NULL; + } + return false; } } data->error(data, exp->token, PSI_WARNING, "Missing declaration '%s' for `return` statement of implementation %s", - name, impl->func->name); + name->val, scope->impl->func->name->val); return false; } -const char *psi_return_exp_get_decl_name(struct psi_return_exp *exp) +zend_string *psi_return_exp_get_decl_name(struct psi_return_exp *exp) { return exp->func ? exp->func->name : exp->set->data.func->var->name; }