skip = ptr;
/* skip internal handler */
- if ((!skip->func || (skip->func->common.type != ZEND_USER_FUNCTION && skip->func->common.type != ZEND_EVAL_CODE)) &&
+ if ((!skip->func || !ZEND_USER_CODE(skip->func->common.type)) &&
skip->prev_execute_data &&
skip->prev_execute_data->opline &&
skip->prev_execute_data->opline->opcode != ZEND_DO_FCALL &&
skip = skip->prev_execute_data;
}
- if (skip->func && (skip->func->common.type == ZEND_USER_FUNCTION || skip->func->common.type == ZEND_EVAL_CODE)) {
+ if (skip->func && ZEND_USER_CODE(skip->func->common.type)) {
filename = skip->func->op_array.filename->val;
lineno = skip->opline->lineno;
} else {
while (prev) {
if (prev->call &&
prev->call->func &&
- prev->call->func->common.type != ZEND_USER_FUNCTION &&
- prev->call->func->common.type != ZEND_EVAL_CODE) {
+ !ZEND_USER_CODE(prev->call->func->common.type)) {
prev = NULL;
break;
}
- if (prev->func && (prev->func->common.type == ZEND_USER_FUNCTION || prev->func->common.type == ZEND_EVAL_CODE)) {
+ if (prev->func && ZEND_USER_CODE(prev->func->common.type)) {
zend_printf(") called at [%s:%d]\n", prev->func->op_array.filename->val, prev->opline->lineno);
break;
}
skip = ptr;
/* skip internal handler */
- if ((!skip->func || (skip->func->common.type != ZEND_USER_FUNCTION && skip->func->common.type != ZEND_EVAL_CODE)) &&
+ if ((!skip->func || !ZEND_USER_CODE(skip->func->common.type)) &&
skip->prev_execute_data &&
skip->prev_execute_data->opline &&
skip->prev_execute_data->opline->opcode != ZEND_DO_FCALL &&
skip = skip->prev_execute_data;
}
- if (skip->func && (skip->func->common.type == ZEND_USER_FUNCTION || skip->func->common.type == ZEND_EVAL_CODE)) {
+ if (skip->func && ZEND_USER_CODE(skip->func->common.type)) {
filename = skip->func->op_array.filename->val;
lineno = skip->opline->lineno;
add_assoc_string_ex(&stack_frame, "file", sizeof("file")-1, (char*)filename);
while (prev) {
if (prev->call &&
prev->call->func &&
- prev->call->func->common.type != ZEND_USER_FUNCTION &&
- prev->call->func->common.type != ZEND_EVAL_CODE &&
+ !ZEND_USER_CODE(prev->call->func->common.type) &&
!(prev->call->func->common.type == ZEND_INTERNAL_FUNCTION &&
(prev->call->func->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER))) {
break;
}
- if (prev->func && (prev->func->common.type == ZEND_USER_FUNCTION || prev->func->common.type == ZEND_EVAL_CODE)) {
+ if (prev->func && ZEND_USER_CODE(prev->func->common.type)) {
// TODO: we have to duplicate it, becaise it may be stored in opcache SHM ???
add_assoc_str_ex(&stack_frame, "file", sizeof("file")-1, STR_DUP(prev->func->op_array.filename, 0));
add_assoc_long_ex(&stack_frame, "line", sizeof("line")-1, prev->opline->lineno);
#define ZEND_EVAL_CODE 4
#define ZEND_OVERLOADED_FUNCTION_TEMPORARY 5
+/* A quick check (type == ZEND_USER_FUNCTION || type == ZEND_EVAL_CODE) */
+#define ZEND_USER_CODE(type) ((type & 1) == 0)
+
#define ZEND_INTERNAL_CLASS 1
#define ZEND_USER_CLASS 2
ZVAL_UNDEF(arg);
}
- if (ptr && ptr->func && (ptr->func->common.type == ZEND_USER_FUNCTION || ptr->func->common.type == ZEND_EVAL_CODE)) {
+ if (ptr && ptr->func && ZEND_USER_CODE(ptr->func->common.type)) {
zend_error(error_type, "Argument %d passed to %s%s%s() must %s%s, %s%s given, called in %s on line %d and defined", arg_num, fclass, fsep, fname, need_msg, need_kind, given_msg, given_kind, ptr->func->op_array.filename->val, ptr->opline->lineno);
} else {
zend_error(error_type, "Argument %d passed to %s%s%s() must %s%s, %s%s given", arg_num, fclass, fsep, fname, need_msg, need_kind, given_msg, given_kind);
const char *func_name = EX(func)->common.function_name ? EX(func)->common.function_name->val : "main";
zend_execute_data *ptr = EX(prev_execute_data);
- if (ptr && ptr->func && (ptr->func->common.type == ZEND_USER_FUNCTION || ptr->func->common.type == ZEND_EVAL_CODE)) {
+ if (ptr && ptr->func && ZEND_USER_CODE(ptr->func->common.type)) {
zend_error(E_WARNING, "Missing argument %u for %s%s%s(), called in %s on line %d and defined", arg_num, class_name, space, func_name, ptr->func->op_array.filename->val, ptr->opline->lineno);
} else {
zend_error(E_WARNING, "Missing argument %u for %s%s%s()", arg_num, class_name, space, func_name);
int used_stack = ZEND_CALL_FRAME_SLOT + num_args;
zend_execute_data *call;
- if (func->type == ZEND_USER_FUNCTION || func->type == ZEND_EVAL_CODE) {
+ if (ZEND_USER_CODE(func->type)) {
used_stack += func->op_array.last_var + func->op_array.T - MIN(func->op_array.num_args, num_args);
}
ZEND_VM_STACK_GROW_IF_NEEDED(used_stack);
/* Search for last called user function */
ex = EG(current_execute_data);
- while (ex && (!ex->func || (ex->func->common.type != ZEND_USER_FUNCTION && ex->func->common.type != ZEND_EVAL_CODE))) {
+ while (ex && (!ex->func || !ZEND_USER_CODE(ex->func->common.type))) {
ex = ex->prev_execute_data;
}
if (!ex) {
{
zend_op *opline, *end;
- if (op_array->type!=ZEND_USER_FUNCTION && op_array->type!=ZEND_EVAL_CODE) {
+ if (!ZEND_USER_CODE(op_array->type)) {
return 0;
}
if (op_array->has_finally_block) {
zend_detach_symbol_table(execute_data);
old_execute_data = EX(prev_execute_data);
while (old_execute_data) {
- if (old_execute_data->func && (old_execute_data->func->op_array.type == ZEND_USER_FUNCTION || old_execute_data->func->op_array.type == ZEND_EVAL_CODE)) {
+ if (old_execute_data->func && ZEND_USER_CODE(old_execute_data->func->op_array.type)) {
if (old_execute_data->symbol_table == symbol_table) {
zend_attach_symbol_table(old_execute_data);
}