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 "context.h"
#include "data.h"
#include "call.h"
+#include "php_psi.h"
+
#include "php.h"
#include "zend_exceptions.h"
-#include "ext/spl/spl_exceptions.h"
struct psi_call_frame_argument *psi_call_frame_argument_init(struct psi_impl_arg *spec,
impl_val *ival, zval *zptr, int is_vararg) {
if (!iarg) {
struct psi_call_frame_argument *frame_arg;
impl_val empty_val = {0};
- zend_string *type_str = zend_string_init(ZEND_STRL("mixed"), 1);
+ zend_string *type_str = psi_string_init_interned(ZEND_STRL("mixed"), 1);
struct psi_impl_arg *carg_spec = psi_impl_arg_init(
psi_impl_type_init(PSI_T_MIXED, type_str),
psi_impl_var_copy(inner_var), NULL);
}
size_t psi_call_frame_num_var_args(struct psi_call_frame *frame) {
- return zend_hash_next_free_element(&frame->arguments);
+ zend_long nfe = zend_hash_next_free_element(&frame->arguments);
+ return nfe > 0 ? nfe : 0;
}
size_t psi_call_frame_num_fixed_args(struct psi_call_frame *frame) {
#else
# define PARAM_PROLOGUE(separate) Z_PARAM_PROLOGUE(1, separate)
#endif
-ZEND_RESULT_CODE psi_call_frame_parse_args(struct psi_call_frame *frame,
+bool psi_call_frame_parse_args(struct psi_call_frame *frame,
zend_execute_data *execute_data) {
size_t i, argc = psi_plist_count(frame->impl->func->args);
zend_error_handling zeh;
rv = zend_parse_parameters_none();
zend_restore_error_handling(&zeh);
- return rv;
+ return rv == SUCCESS;
}
ZEND_PARSE_PARAMETERS_START(
ival.zend.cb->fcc = fcc;
}
} else {
- error_code = ZPP_ERROR_FAILURE;
+ _error_code = ZPP_ERROR_FAILURE;
break;
}
}
ZEND_PARSE_PARAMETERS_END_EX(
zend_restore_error_handling(&zeh);
- return FAILURE;
+ return false;
);
/* set up defaults */
}
zend_restore_error_handling(&zeh);
- return SUCCESS;
+ return true;
}
void psi_call_frame_enter(struct psi_call_frame *frame) {
frame->rpointer = rv_sym->ptr = rv_sym->ival_ptr;
}
-ZEND_RESULT_CODE psi_call_frame_do_let(struct psi_call_frame *frame) {
+bool psi_call_frame_do_let(struct psi_call_frame *frame) {
size_t i;
struct psi_let_stmt *let;
struct psi_decl_arg *arg;
void *temp = NULL;
frame_arg = psi_call_frame_get_var_argument(frame, i);
+ if (!frame_arg) {
+ return false;
+ }
switch (frame_arg->va_type) {
case PSI_T_BOOL: let_fn = psi_let_boolval; break;
case PSI_T_INT: let_fn = psi_let_intval; break;
case PSI_T_STRING: let_fn = psi_let_strval; break;
default:
assert(0);
+ return false;
}
frame_arg->ival_ptr = let_fn(&frame_arg->temp_val, NULL, frame_arg->va_type,
}
}
- return SUCCESS;
+ return true;
}
-ZEND_RESULT_CODE psi_call_frame_do_assert(struct psi_call_frame *frame, enum psi_assert_kind kind) {
+bool psi_call_frame_do_assert(struct psi_call_frame *frame, enum psi_assert_kind kind) {
size_t i = 0;
struct psi_assert_stmt *ass;
while (psi_plist_get(frame->impl->stmts.ass, i++, &ass)) {
if (ass->kind == kind) {
if (!psi_assert_stmt_exec(ass, frame)) {
- char *message = psi_assert_stmt_message(ass);
- zend_throw_exception(kind == PSI_ASSERT_PRE
- ? spl_ce_InvalidArgumentException
- : spl_ce_UnexpectedValueException, message, 0);
- free(message);
- return FAILURE;
+ psi_assert_stmt_throw(ass);
+ return false;
}
}
}
- return SUCCESS;
+ return true;
}
void psi_call_frame_do_call(struct psi_call_frame *frame) {
}
frame_arg = psi_call_frame_get_argument(frame, cb->func->var->fqn);
+ if (!frame_arg) {
+ return;
+ }
/* callback into userland */
ZVAL_UNDEF(&return_value);
rc = zend_fcall_info_call(&frame_arg->ival_ptr->zend.cb->fci,
&frame_arg->ival_ptr->zend.cb->fcc, &return_value, NULL);
assert(rc == SUCCESS);
+ (void) rc;
/* marshal return value of the userland call */
frame_arg->zval_ptr = &return_value;
efree(auto_list);
}
-#include "php_psi.h"
-
void psi_call_frame_free(struct psi_call_frame *frame) {
zend_hash_destroy(&frame->arguments);
zend_hash_destroy(&frame->symbols);