zend_string'ify
[m6w6/ext-psi] / src / types / return_stmt.c
index 123a8dfd2cdf01adc1bf4760a1931a1ae253cb46..8ff646d3d9448eea3f400df7c548ccab3e94283e 100644 (file)
@@ -46,9 +46,7 @@ void psi_return_stmt_free(struct psi_return_stmt **ret_ptr)
                struct psi_return_stmt *ret = *ret_ptr;
 
                *ret_ptr = NULL;
-               if (ret->token) {
-                       free(ret->token);
-               }
+               psi_token_free(&ret->token);
                psi_return_exp_free(&ret->exp);
                free(ret);
        }
@@ -61,12 +59,13 @@ void psi_return_stmt_dump(int fd, struct psi_return_stmt *ret)
        dprintf(fd, ";\n");
 }
 
-bool psi_return_stmt_validate(struct psi_data *data, struct psi_impl *impl)
+bool psi_return_stmt_validate(struct psi_data *data,
+               struct psi_validate_scope *scope)
 {
        struct psi_return_stmt *ret;
-       size_t count = psi_plist_count(impl->stmts.ret);
+       size_t count = psi_plist_count(scope->impl->stmts.ret);
 
-       psi_plist_get(impl->stmts.ret, 0, &ret);
+       psi_plist_get(scope->impl->stmts.ret, 0, &ret);
 
        /*
         * we must have exactly one ret stmt declaring the native func to call
@@ -77,18 +76,18 @@ bool psi_return_stmt_validate(struct psi_data *data, struct psi_impl *impl)
                data->error(data, ret->token, PSI_WARNING,
                                "Too many `return` statements for implementation %s;"
                                " found %zu, exactly one is required",
-                               impl->func->name, count);
+                               scope->impl->func->name->val, count);
                return false;
        case 0:
-               data->error(data, impl->func->token, PSI_WARNING,
+               data->error(data, scope->impl->func->token, PSI_WARNING,
                                "Missing `return` statement for implementation %s",
-                               impl->func->name);
+                               scope->impl->func->name->val);
                return false;
        case 1:
                break;
        }
 
-       if (!psi_return_exp_validate(data, ret->exp, impl)) {
+       if (!psi_return_exp_validate(data, ret->exp, scope)) {
                return false;
        }