OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
-#include "php_psi_stdinc.h"
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#else
+# include "php_config.h"
+#endif
#include "data.h"
#include "call.h"
struct psi_return_exp *psi_return_exp_init(struct psi_decl_var *func,
struct psi_plist *args, struct psi_set_exp *set)
{
- struct psi_return_exp *exp = calloc(1, sizeof(*exp));
+ struct psi_return_exp *exp = pecalloc(1, sizeof(*exp), 1);
exp->func = func;
exp->args = args;
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);
}
}
}
-void psi_return_exp_dump(int fd, struct psi_return_exp *exp)
+void psi_return_exp_dump(struct psi_dump *dump, struct psi_return_exp *exp)
{
if (exp->func) {
- psi_decl_var_dump(fd, exp->func);
- dprintf(fd, "(");
+ psi_decl_var_dump(dump, exp->func);
+ PSI_DUMP(dump, "(");
if (exp->args) {
size_t i = 0;
struct psi_decl_var *arg;
while (psi_plist_get(exp->args, i++, &arg)) {
if (i > 1) {
- dprintf(fd, ", ");
+ PSI_DUMP(dump, ", ");
}
- psi_decl_var_dump(fd, arg);
+ psi_decl_var_dump(dump, arg);
}
}
- dprintf(fd, ")");
+ PSI_DUMP(dump, ")");
}
if (exp->set) {
if (exp->func) {
- dprintf(fd, " as ");
+ PSI_DUMP(dump, " as ");
}
- psi_set_exp_dump(fd, exp->set, 1, 1);
+ psi_set_exp_dump(dump, exp->set, 1, 1);
}
}
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;
}
}
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;
}