-int validate_return_stmt(struct psi_data *data, impl *impl) {
- return_stmt *ret;
-
- /* we must have exactly one ret stmt delcaring the native func to call */
- /* and which type cast to apply */
- if (impl->stmts->ret.count != 1) {
- if (impl->stmts->ret.count > 1) {
- data->error(data, impl->stmts->ret.list[1]->token, PSI_WARNING,
- "Too many `return` statements for implmentation %s;"
- " found %zu, exactly one is needed",
- impl->func->name, impl->stmts->ret.count);
- } else {
- data->error(data, impl->func->token, PSI_WARNING,
- "Missing `return` statement for implementation %s",
- impl->func->name);
- }
- return 0;
+bool psi_return_stmt_validate(struct psi_data *data, struct psi_impl *impl)
+{
+ size_t i = 0;
+ struct psi_decl *decl;
+ struct psi_return_stmt *ret;
+ size_t count = psi_plist_count(impl->stmts.ret);
+
+ psi_plist_get(impl->stmts.ret, 0, &ret);
+
+ /*
+ * we must have exactly one ret stmt declaring the native func to call
+ * and which type cast to apply
+ */
+ switch (count) {
+ default:
+ data->error(data, ret->token, PSI_WARNING,
+ "Too many `return` statements for implementation %s;"
+ " found %zu, exactly one is required",
+ impl->func->name, count);
+ return false;
+ case 0:
+ data->error(data, impl->func->token, PSI_WARNING,
+ "Missing `return` statement for implementation %s",
+ impl->func->name);
+ return false;
+ case 1:
+ break;