Back to index

php5  5.3.10
Defines | Functions
zend_operators.h File Reference
#include <errno.h>
#include <math.h>
#include <assert.h>
#include "zend_strtod.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define ZEND_IS_DIGIT(c)   ((c) >= '0' && (c) <= '9')
#define ZEND_IS_XDIGIT(c)   (((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f'))
#define convert_to_string(op)   if ((op)->type != IS_STRING) { _convert_to_string((op) ZEND_FILE_LINE_CC); }
#define convert_to_ex_master(ppzv, lower_type, upper_type)
#define convert_to_explicit_type(pzv, type)
#define convert_to_explicit_type_ex(ppzv, str_type)
#define convert_to_boolean_ex(ppzv)   convert_to_ex_master(ppzv, boolean, BOOL)
#define convert_to_long_ex(ppzv)   convert_to_ex_master(ppzv, long, LONG)
#define convert_to_double_ex(ppzv)   convert_to_ex_master(ppzv, double, DOUBLE)
#define convert_to_string_ex(ppzv)   convert_to_ex_master(ppzv, string, STRING)
#define convert_to_array_ex(ppzv)   convert_to_ex_master(ppzv, array, ARRAY)
#define convert_to_object_ex(ppzv)   convert_to_ex_master(ppzv, object, OBJECT)
#define convert_to_null_ex(ppzv)   convert_to_ex_master(ppzv, null, NULL)
#define convert_scalar_to_number_ex(ppzv)
#define Z_LVAL(zval)   (zval).value.lval
#define Z_BVAL(zval)   ((zend_bool)(zval).value.lval)
#define Z_DVAL(zval)   (zval).value.dval
#define Z_STRVAL(zval)   (zval).value.str.val
#define Z_STRLEN(zval)   (zval).value.str.len
#define Z_ARRVAL(zval)   (zval).value.ht
#define Z_OBJVAL(zval)   (zval).value.obj
#define Z_OBJ_HANDLE(zval)   Z_OBJVAL(zval).handle
#define Z_OBJ_HT(zval)   Z_OBJVAL(zval).handlers
#define Z_OBJCE(zval)   zend_get_class_entry(&(zval) TSRMLS_CC)
#define Z_OBJPROP(zval)   Z_OBJ_HT((zval))->get_properties(&(zval) TSRMLS_CC)
#define Z_OBJ_HANDLER(zval, hf)   Z_OBJ_HT((zval))->hf
#define Z_RESVAL(zval)   (zval).value.lval
#define Z_OBJDEBUG(zval, is_tmp)   (Z_OBJ_HANDLER((zval),get_debug_info)?Z_OBJ_HANDLER((zval),get_debug_info)(&(zval),&is_tmp TSRMLS_CC):(is_tmp=0,Z_OBJ_HANDLER((zval),get_properties)?Z_OBJPROP(zval):NULL))
#define Z_LVAL_P(zval_p)   Z_LVAL(*zval_p)
#define Z_BVAL_P(zval_p)   Z_BVAL(*zval_p)
#define Z_DVAL_P(zval_p)   Z_DVAL(*zval_p)
#define Z_STRVAL_P(zval_p)   Z_STRVAL(*zval_p)
#define Z_STRLEN_P(zval_p)   Z_STRLEN(*zval_p)
#define Z_ARRVAL_P(zval_p)   Z_ARRVAL(*zval_p)
#define Z_OBJPROP_P(zval_p)   Z_OBJPROP(*zval_p)
#define Z_OBJCE_P(zval_p)   Z_OBJCE(*zval_p)
#define Z_RESVAL_P(zval_p)   Z_RESVAL(*zval_p)
#define Z_OBJVAL_P(zval_p)   Z_OBJVAL(*zval_p)
#define Z_OBJ_HANDLE_P(zval_p)   Z_OBJ_HANDLE(*zval_p)
#define Z_OBJ_HT_P(zval_p)   Z_OBJ_HT(*zval_p)
#define Z_OBJ_HANDLER_P(zval_p, h)   Z_OBJ_HANDLER(*zval_p, h)
#define Z_OBJDEBUG_P(zval_p, is_tmp)   Z_OBJDEBUG(*zval_p,is_tmp)
#define Z_LVAL_PP(zval_pp)   Z_LVAL(**zval_pp)
#define Z_BVAL_PP(zval_pp)   Z_BVAL(**zval_pp)
#define Z_DVAL_PP(zval_pp)   Z_DVAL(**zval_pp)
#define Z_STRVAL_PP(zval_pp)   Z_STRVAL(**zval_pp)
#define Z_STRLEN_PP(zval_pp)   Z_STRLEN(**zval_pp)
#define Z_ARRVAL_PP(zval_pp)   Z_ARRVAL(**zval_pp)
#define Z_OBJPROP_PP(zval_pp)   Z_OBJPROP(**zval_pp)
#define Z_OBJCE_PP(zval_pp)   Z_OBJCE(**zval_pp)
#define Z_RESVAL_PP(zval_pp)   Z_RESVAL(**zval_pp)
#define Z_OBJVAL_PP(zval_pp)   Z_OBJVAL(**zval_pp)
#define Z_OBJ_HANDLE_PP(zval_p)   Z_OBJ_HANDLE(**zval_p)
#define Z_OBJ_HT_PP(zval_p)   Z_OBJ_HT(**zval_p)
#define Z_OBJ_HANDLER_PP(zval_p, h)   Z_OBJ_HANDLER(**zval_p, h)
#define Z_OBJDEBUG_PP(zval_pp, is_tmp)   Z_OBJDEBUG(**zval_pp,is_tmp)
#define Z_TYPE(zval)   (zval).type
#define Z_TYPE_P(zval_p)   Z_TYPE(*zval_p)
#define Z_TYPE_PP(zval_pp)   Z_TYPE(**zval_pp)
#define zend_update_current_locale()

Functions

ZEND_API int add_function (zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int sub_function (zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int mul_function (zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int div_function (zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int mod_function (zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int boolean_xor_function (zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int boolean_not_function (zval *result, zval *op1 TSRMLS_DC)
ZEND_API int bitwise_not_function (zval *result, zval *op1 TSRMLS_DC)
ZEND_API int bitwise_or_function (zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int bitwise_and_function (zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int bitwise_xor_function (zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int shift_left_function (zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int shift_right_function (zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int concat_function (zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int is_equal_function (zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int is_identical_function (zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int is_not_identical_function (zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int is_not_equal_function (zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int is_smaller_function (zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int is_smaller_or_equal_function (zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API zend_bool instanceof_function_ex (const zend_class_entry *instance_ce, const zend_class_entry *ce, zend_bool interfaces_only TSRMLS_DC)
ZEND_API zend_bool instanceof_function (const zend_class_entry *instance_ce, const zend_class_entry *ce TSRMLS_DC)
static zend_always_inline long zend_dval_to_lval (double d)
static zend_uchar is_numeric_string (const char *str, int length, long *lval, double *dval, int allow_errors)
 Checks whether the string "str" with length "length" is numeric.
static char * zend_memnstr (char *haystack, char *needle, int needle_len, char *end)
static void * zend_memrchr (const void *s, int c, size_t n)
ZEND_API int increment_function (zval *op1)
ZEND_API int decrement_function (zval *op2)
ZEND_API void convert_scalar_to_number (zval *op TSRMLS_DC)
ZEND_API void _convert_to_string (zval *op ZEND_FILE_LINE_DC)
ZEND_API void convert_to_long (zval *op)
ZEND_API void convert_to_double (zval *op)
ZEND_API void convert_to_long_base (zval *op, int base)
ZEND_API void convert_to_null (zval *op)
ZEND_API void convert_to_boolean (zval *op)
ZEND_API void convert_to_array (zval *op)
ZEND_API void convert_to_object (zval *op)
ZEND_API void multi_convert_to_long_ex (int argc,...)
ZEND_API void multi_convert_to_double_ex (int argc,...)
ZEND_API void multi_convert_to_string_ex (int argc,...)
ZEND_API int add_char_to_string (zval *result, const zval *op1, const zval *op2)
ZEND_API int add_string_to_string (zval *result, const zval *op1, const zval *op2)
ZEND_API double zend_string_to_double (const char *number, zend_uint length)
ZEND_API int zval_is_true (zval *op)
ZEND_API int compare_function (zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int numeric_compare_function (zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int string_compare_function (zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API void zend_str_tolower (char *str, unsigned int length)
ZEND_API char * zend_str_tolower_copy (char *dest, const char *source, unsigned int length)
ZEND_API char * zend_str_tolower_dup (const char *source, unsigned int length)
ZEND_API int zend_binary_zval_strcmp (zval *s1, zval *s2)
ZEND_API int zend_binary_zval_strncmp (zval *s1, zval *s2, zval *s3)
ZEND_API int zend_binary_zval_strcasecmp (zval *s1, zval *s2)
ZEND_API int zend_binary_zval_strncasecmp (zval *s1, zval *s2, zval *s3)
ZEND_API int zend_binary_strcmp (const char *s1, uint len1, const char *s2, uint len2)
ZEND_API int zend_binary_strncmp (const char *s1, uint len1, const char *s2, uint len2, uint length)
ZEND_API int zend_binary_strcasecmp (const char *s1, uint len1, const char *s2, uint len2)
ZEND_API int zend_binary_strncasecmp (const char *s1, uint len1, const char *s2, uint len2, uint length)
ZEND_API void zendi_smart_strcmp (zval *result, zval *s1, zval *s2)
ZEND_API void zend_compare_symbol_tables (zval *result, HashTable *ht1, HashTable *ht2 TSRMLS_DC)
ZEND_API void zend_compare_arrays (zval *result, zval *a1, zval *a2 TSRMLS_DC)
ZEND_API void zend_compare_objects (zval *result, zval *o1, zval *o2 TSRMLS_DC)
ZEND_API int zend_atoi (const char *str, int str_len)
ZEND_API long zend_atol (const char *str, int str_len)
ZEND_API void zend_locale_sprintf_double (zval *op ZEND_FILE_LINE_DC)

Define Documentation

#define convert_scalar_to_number_ex (   ppzv)
Value:
if (Z_TYPE_PP(ppzv)!=IS_LONG && Z_TYPE_PP(ppzv)!=IS_DOUBLE) {  \
              if (!Z_ISREF_PP(ppzv)) {                                                            \
                     SEPARATE_ZVAL(ppzv);                                                         \
              }                                                                                                        \
              convert_scalar_to_number(*ppzv TSRMLS_CC);                                   \
       }

Definition at line 380 of file zend_operators.h.

#define convert_to_array_ex (   ppzv)    convert_to_ex_master(ppzv, array, ARRAY)

Definition at line 376 of file zend_operators.h.

#define convert_to_boolean_ex (   ppzv)    convert_to_ex_master(ppzv, boolean, BOOL)

Definition at line 372 of file zend_operators.h.

#define convert_to_double_ex (   ppzv)    convert_to_ex_master(ppzv, double, DOUBLE)

Definition at line 374 of file zend_operators.h.

#define convert_to_ex_master (   ppzv,
  lower_type,
  upper_type 
)
Value:
if (Z_TYPE_PP(ppzv)!=IS_##upper_type) {                               \
              SEPARATE_ZVAL_IF_NOT_REF(ppzv);                                       \
              convert_to_##lower_type(*ppzv);                                       \
       }

Definition at line 330 of file zend_operators.h.

#define convert_to_explicit_type (   pzv,
  type 
)
Value:
do {                                                                  \
              switch (type) {                                                \
                     case IS_NULL:                                    \
                            convert_to_null(pzv);                     \
                            break;                                           \
                     case IS_LONG:                                    \
                            convert_to_long(pzv);                     \
                            break;                                           \
                     case IS_DOUBLE:                                         \
                            convert_to_double(pzv);                   \
                            break;                                           \
                     case IS_BOOL:                                    \
                            convert_to_boolean(pzv);           \
                            break;                                           \
                     case IS_ARRAY:                                          \
                            convert_to_array(pzv);                    \
                            break;                                           \
                     case IS_OBJECT:                                         \
                            convert_to_object(pzv);                   \
                            break;                                           \
                     case IS_STRING:                                         \
                            convert_to_string(pzv);                   \
                            break;                                           \
                     default:                                                \
                            assert(0);                                       \
                            break;                                           \
              }                                                                     \
       } while (0);

Definition at line 336 of file zend_operators.h.

#define convert_to_explicit_type_ex (   ppzv,
  str_type 
)
Value:
if (Z_TYPE_PP(ppzv) != str_type) {                      \
              SEPARATE_ZVAL_IF_NOT_REF(ppzv);                         \
              convert_to_explicit_type(*ppzv, str_type);       \
       }

Definition at line 366 of file zend_operators.h.

#define convert_to_long_ex (   ppzv)    convert_to_ex_master(ppzv, long, LONG)

Definition at line 373 of file zend_operators.h.

#define convert_to_null_ex (   ppzv)    convert_to_ex_master(ppzv, null, NULL)

Definition at line 378 of file zend_operators.h.

#define convert_to_object_ex (   ppzv)    convert_to_ex_master(ppzv, object, OBJECT)

Definition at line 377 of file zend_operators.h.

#define convert_to_string (   op)    if ((op)->type != IS_STRING) { _convert_to_string((op) ZEND_FILE_LINE_CC); }

Definition at line 294 of file zend_operators.h.

#define convert_to_string_ex (   ppzv)    convert_to_ex_master(ppzv, string, STRING)

Definition at line 375 of file zend_operators.h.

#define Z_ARRVAL (   zval)    (zval).value.ht

Definition at line 394 of file zend_operators.h.

#define Z_ARRVAL_P (   zval_p)    Z_ARRVAL(*zval_p)

Definition at line 409 of file zend_operators.h.

#define Z_ARRVAL_PP (   zval_pp)    Z_ARRVAL(**zval_pp)

Definition at line 424 of file zend_operators.h.

#define Z_BVAL (   zval)    ((zend_bool)(zval).value.lval)

Definition at line 390 of file zend_operators.h.

#define Z_BVAL_P (   zval_p)    Z_BVAL(*zval_p)

Definition at line 405 of file zend_operators.h.

#define Z_BVAL_PP (   zval_pp)    Z_BVAL(**zval_pp)

Definition at line 420 of file zend_operators.h.

#define Z_DVAL (   zval)    (zval).value.dval

Definition at line 391 of file zend_operators.h.

#define Z_DVAL_P (   zval_p)    Z_DVAL(*zval_p)

Definition at line 406 of file zend_operators.h.

#define Z_DVAL_PP (   zval_pp)    Z_DVAL(**zval_pp)

Definition at line 421 of file zend_operators.h.

#define Z_LVAL (   zval)    (zval).value.lval

Definition at line 389 of file zend_operators.h.

#define Z_LVAL_P (   zval_p)    Z_LVAL(*zval_p)

Definition at line 404 of file zend_operators.h.

#define Z_LVAL_PP (   zval_pp)    Z_LVAL(**zval_pp)

Definition at line 419 of file zend_operators.h.

#define Z_OBJ_HANDLE (   zval)    Z_OBJVAL(zval).handle

Definition at line 396 of file zend_operators.h.

#define Z_OBJ_HANDLE_P (   zval_p)    Z_OBJ_HANDLE(*zval_p)

Definition at line 414 of file zend_operators.h.

#define Z_OBJ_HANDLE_PP (   zval_p)    Z_OBJ_HANDLE(**zval_p)

Definition at line 429 of file zend_operators.h.

#define Z_OBJ_HANDLER (   zval,
  hf 
)    Z_OBJ_HT((zval))->hf

Definition at line 400 of file zend_operators.h.

#define Z_OBJ_HANDLER_P (   zval_p,
 
)    Z_OBJ_HANDLER(*zval_p, h)

Definition at line 416 of file zend_operators.h.

#define Z_OBJ_HANDLER_PP (   zval_p,
 
)    Z_OBJ_HANDLER(**zval_p, h)

Definition at line 431 of file zend_operators.h.

#define Z_OBJ_HT (   zval)    Z_OBJVAL(zval).handlers

Definition at line 397 of file zend_operators.h.

#define Z_OBJ_HT_P (   zval_p)    Z_OBJ_HT(*zval_p)

Definition at line 415 of file zend_operators.h.

#define Z_OBJ_HT_PP (   zval_p)    Z_OBJ_HT(**zval_p)

Definition at line 430 of file zend_operators.h.

#define Z_OBJCE (   zval)    zend_get_class_entry(&(zval) TSRMLS_CC)

Definition at line 398 of file zend_operators.h.

#define Z_OBJCE_P (   zval_p)    Z_OBJCE(*zval_p)

Definition at line 411 of file zend_operators.h.

#define Z_OBJCE_PP (   zval_pp)    Z_OBJCE(**zval_pp)

Definition at line 426 of file zend_operators.h.

#define Z_OBJDEBUG (   zval,
  is_tmp 
)    (Z_OBJ_HANDLER((zval),get_debug_info)?Z_OBJ_HANDLER((zval),get_debug_info)(&(zval),&is_tmp TSRMLS_CC):(is_tmp=0,Z_OBJ_HANDLER((zval),get_properties)?Z_OBJPROP(zval):NULL))

Definition at line 402 of file zend_operators.h.

#define Z_OBJDEBUG_P (   zval_p,
  is_tmp 
)    Z_OBJDEBUG(*zval_p,is_tmp)

Definition at line 417 of file zend_operators.h.

#define Z_OBJDEBUG_PP (   zval_pp,
  is_tmp 
)    Z_OBJDEBUG(**zval_pp,is_tmp)

Definition at line 432 of file zend_operators.h.

#define Z_OBJPROP (   zval)    Z_OBJ_HT((zval))->get_properties(&(zval) TSRMLS_CC)

Definition at line 399 of file zend_operators.h.

#define Z_OBJPROP_P (   zval_p)    Z_OBJPROP(*zval_p)

Definition at line 410 of file zend_operators.h.

#define Z_OBJPROP_PP (   zval_pp)    Z_OBJPROP(**zval_pp)

Definition at line 425 of file zend_operators.h.

#define Z_OBJVAL (   zval)    (zval).value.obj

Definition at line 395 of file zend_operators.h.

#define Z_OBJVAL_P (   zval_p)    Z_OBJVAL(*zval_p)

Definition at line 413 of file zend_operators.h.

#define Z_OBJVAL_PP (   zval_pp)    Z_OBJVAL(**zval_pp)

Definition at line 428 of file zend_operators.h.

#define Z_RESVAL (   zval)    (zval).value.lval

Definition at line 401 of file zend_operators.h.

#define Z_RESVAL_P (   zval_p)    Z_RESVAL(*zval_p)

Definition at line 412 of file zend_operators.h.

#define Z_RESVAL_PP (   zval_pp)    Z_RESVAL(**zval_pp)

Definition at line 427 of file zend_operators.h.

#define Z_STRLEN (   zval)    (zval).value.str.len

Definition at line 393 of file zend_operators.h.

#define Z_STRLEN_P (   zval_p)    Z_STRLEN(*zval_p)

Definition at line 408 of file zend_operators.h.

#define Z_STRLEN_PP (   zval_pp)    Z_STRLEN(**zval_pp)

Definition at line 423 of file zend_operators.h.

#define Z_STRVAL (   zval)    (zval).value.str.val

Definition at line 392 of file zend_operators.h.

#define Z_STRVAL_P (   zval_p)    Z_STRVAL(*zval_p)

Definition at line 407 of file zend_operators.h.

#define Z_STRVAL_PP (   zval_pp)    Z_STRVAL(**zval_pp)

Definition at line 422 of file zend_operators.h.

#define Z_TYPE (   zval)    (zval).type

Definition at line 434 of file zend_operators.h.

#define Z_TYPE_P (   zval_p)    Z_TYPE(*zval_p)

Definition at line 435 of file zend_operators.h.

#define Z_TYPE_PP (   zval_pp)    Z_TYPE(**zval_pp)

Definition at line 436 of file zend_operators.h.

#define ZEND_IS_DIGIT (   c)    ((c) >= '0' && (c) <= '9')

Definition at line 87 of file zend_operators.h.

#define ZEND_IS_XDIGIT (   c)    (((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f'))

Definition at line 88 of file zend_operators.h.

Definition at line 448 of file zend_operators.h.


Function Documentation

ZEND_API void _convert_to_string ( zval *op  ZEND_FILE_LINE_DC)

Definition at line 541 of file zend_operators.c.

{
       long lval;
       double dval;

       switch (Z_TYPE_P(op)) {
              case IS_NULL:
                     Z_STRVAL_P(op) = STR_EMPTY_ALLOC();
                     Z_STRLEN_P(op) = 0;
                     break;
              case IS_STRING:
                     break;
              case IS_BOOL:
                     if (Z_LVAL_P(op)) {
                            Z_STRVAL_P(op) = estrndup_rel("1", 1);
                            Z_STRLEN_P(op) = 1;
                     } else {
                            Z_STRVAL_P(op) = STR_EMPTY_ALLOC();
                            Z_STRLEN_P(op) = 0;
                     }
                     break;
              case IS_RESOURCE: {
                     long tmp = Z_LVAL_P(op);
                     TSRMLS_FETCH();

                     zend_list_delete(Z_LVAL_P(op));
                     Z_STRLEN_P(op) = zend_spprintf(&Z_STRVAL_P(op), 0, "Resource id #%ld", tmp);
                     break;
              }
              case IS_LONG:
                     lval = Z_LVAL_P(op);

                     Z_STRLEN_P(op) = zend_spprintf(&Z_STRVAL_P(op), 0, "%ld", lval);
                     break;
              case IS_DOUBLE: {
                     TSRMLS_FETCH();
                     dval = Z_DVAL_P(op);
                     Z_STRLEN_P(op) = zend_spprintf(&Z_STRVAL_P(op), 0, "%.*G", (int) EG(precision), dval);
                     /* %G already handles removing trailing zeros from the fractional part, yay */
                     break;
              }
              case IS_ARRAY:
                     zend_error(E_NOTICE, "Array to string conversion");
                     zval_dtor(op);
                     Z_STRVAL_P(op) = estrndup_rel("Array", sizeof("Array")-1);
                     Z_STRLEN_P(op) = sizeof("Array")-1;
                     break;
              case IS_OBJECT: {
                     TSRMLS_FETCH();

                     convert_object_to_type(op, IS_STRING, convert_to_string);

                     if (Z_TYPE_P(op) == IS_STRING) {
                            return;
                     }

                     zend_error(E_NOTICE, "Object of class %s to string conversion", Z_OBJCE_P(op)->name);
                     zval_dtor(op);
                     Z_STRVAL_P(op) = estrndup_rel("Object", sizeof("Object")-1);
                     Z_STRLEN_P(op) = sizeof("Object")-1;
                     break;
              }
              default:
                     zval_dtor(op);
                     ZVAL_BOOL(op, 0);
                     break;
       }
       Z_TYPE_P(op) = IS_STRING;
}

Here is the call graph for this function:

ZEND_API int add_char_to_string ( zval *  result,
const zval *  op1,
const zval *  op2 
)

Definition at line 1200 of file zend_operators.c.

{
       Z_STRLEN_P(result) = Z_STRLEN_P(op1) + 1;
       Z_STRVAL_P(result) = (char *) erealloc(Z_STRVAL_P(op1), Z_STRLEN_P(result)+1);
       Z_STRVAL_P(result)[Z_STRLEN_P(result) - 1] = (char) Z_LVAL_P(op2);
       Z_STRVAL_P(result)[Z_STRLEN_P(result)] = 0;
       Z_TYPE_P(result) = IS_STRING;
       return SUCCESS;
}

Here is the caller graph for this function:

ZEND_API int add_function ( zval *  result,
zval *  op1,
zval *op2  TSRMLS_DC 
)

Definition at line 758 of file zend_operators.c.

{
       zval op1_copy, op2_copy;
       int converted = 0;

       while (1) {
              switch (TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2))) {
                     case TYPE_PAIR(IS_LONG, IS_LONG): {
                            long lval = Z_LVAL_P(op1) + Z_LVAL_P(op2);

                            /* check for overflow by comparing sign bits */
                            if ((Z_LVAL_P(op1) & LONG_SIGN_MASK) == (Z_LVAL_P(op2) & LONG_SIGN_MASK)
                                   && (Z_LVAL_P(op1) & LONG_SIGN_MASK) != (lval & LONG_SIGN_MASK)) {

                                   ZVAL_DOUBLE(result, (double) Z_LVAL_P(op1) + (double) Z_LVAL_P(op2));
                            } else {
                                   ZVAL_LONG(result, lval);
                            }
                            return SUCCESS;
                     }

                     case TYPE_PAIR(IS_LONG, IS_DOUBLE):
                            ZVAL_DOUBLE(result, ((double)Z_LVAL_P(op1)) + Z_DVAL_P(op2));
                            return SUCCESS;

                     case TYPE_PAIR(IS_DOUBLE, IS_LONG):
                            ZVAL_DOUBLE(result, Z_DVAL_P(op1) + ((double)Z_LVAL_P(op2)));
                            return SUCCESS;

                     case TYPE_PAIR(IS_DOUBLE, IS_DOUBLE):
                            ZVAL_DOUBLE(result, Z_DVAL_P(op1) + Z_DVAL_P(op2));
                            return SUCCESS;

                     case TYPE_PAIR(IS_ARRAY, IS_ARRAY): {
                            zval *tmp;

                            if ((result == op1) && (result == op2)) {
                                   /* $a += $a */
                                   return SUCCESS;
                            }
                            if (result != op1) {
                                   *result = *op1;
                                   zval_copy_ctor(result);
                            }
                            zend_hash_merge(Z_ARRVAL_P(result), Z_ARRVAL_P(op2), (void (*)(void *pData)) zval_add_ref, (void *) &tmp, sizeof(zval *), 0);
                            return SUCCESS;
                     }

                     default:
                            if (!converted) {
                                   zendi_convert_scalar_to_number(op1, op1_copy, result);
                                   zendi_convert_scalar_to_number(op2, op2_copy, result);
                                   converted = 1;
                            } else {
                                   zend_error(E_ERROR, "Unsupported operand types");
                                   return FAILURE; /* unknown datatype */
                            }
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API int add_string_to_string ( zval *  result,
const zval *  op1,
const zval *  op2 
)

Definition at line 1212 of file zend_operators.c.

{
       int length = Z_STRLEN_P(op1) + Z_STRLEN_P(op2);

       Z_STRVAL_P(result) = (char *) erealloc(Z_STRVAL_P(op1), length+1);
       memcpy(Z_STRVAL_P(result)+Z_STRLEN_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op2));
       Z_STRVAL_P(result)[length] = 0;
       Z_STRLEN_P(result) = length;
       Z_TYPE_P(result) = IS_STRING;
       return SUCCESS;
}

Here is the caller graph for this function:

ZEND_API int bitwise_and_function ( zval *  result,
zval *  op1,
zval *op2  TSRMLS_DC 
)

Definition at line 1090 of file zend_operators.c.

{
       zval op1_copy, op2_copy;
       long op1_lval;

       if (Z_TYPE_P(op1) == IS_STRING && Z_TYPE_P(op2) == IS_STRING) {
              zval *longer, *shorter;
              char *result_str;
              int i, result_len;

              if (Z_STRLEN_P(op1) >= Z_STRLEN_P(op2)) {
                     longer = op1;
                     shorter = op2;
              } else {
                     longer = op2;
                     shorter = op1;
              }

              Z_TYPE_P(result) = IS_STRING;
              result_len = Z_STRLEN_P(shorter);
              result_str = estrndup(Z_STRVAL_P(shorter), Z_STRLEN_P(shorter));
              for (i = 0; i < Z_STRLEN_P(shorter); i++) {
                     result_str[i] &= Z_STRVAL_P(longer)[i];
              }
              if (result==op1) {
                     STR_FREE(Z_STRVAL_P(result));
              }
              Z_STRVAL_P(result) = result_str;
              Z_STRLEN_P(result) = result_len;
              return SUCCESS;
       }


       zendi_convert_to_long(op1, op1_copy, result);
       op1_lval = Z_LVAL_P(op1);
       zendi_convert_to_long(op2, op2_copy, result);

       ZVAL_LONG(result, op1_lval & Z_LVAL_P(op2));
       return SUCCESS;
}

Here is the caller graph for this function:

ZEND_API int bitwise_not_function ( zval *  result,
zval *op1  TSRMLS_DC 
)

Definition at line 1022 of file zend_operators.c.

{
       zval op1_copy = *op1;

       op1 = &op1_copy;

       if (Z_TYPE_P(op1) == IS_LONG) {
              ZVAL_LONG(result, ~Z_LVAL_P(op1));
              return SUCCESS;
       } else if (Z_TYPE_P(op1) == IS_DOUBLE) {
              ZVAL_LONG(result, ~zend_dval_to_lval(Z_DVAL_P(op1)));
              return SUCCESS;
       } else if (Z_TYPE_P(op1) == IS_STRING) {
              int i;

              Z_TYPE_P(result) = IS_STRING;
              Z_STRVAL_P(result) = estrndup(Z_STRVAL_P(op1), Z_STRLEN_P(op1));
              Z_STRLEN_P(result) = Z_STRLEN_P(op1);
              for (i = 0; i < Z_STRLEN_P(op1); i++) {
                     Z_STRVAL_P(result)[i] = ~Z_STRVAL_P(op1)[i];
              }
              return SUCCESS;
       }
       zend_error(E_ERROR, "Unsupported operand types");
       return FAILURE;                           /* unknown datatype */
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API int bitwise_or_function ( zval *  result,
zval *  op1,
zval *op2  TSRMLS_DC 
)

Definition at line 1050 of file zend_operators.c.

{
       zval op1_copy, op2_copy;
       long op1_lval;

       if (Z_TYPE_P(op1) == IS_STRING && Z_TYPE_P(op2) == IS_STRING) {
              zval *longer, *shorter;
              char *result_str;
              int i, result_len;

              if (Z_STRLEN_P(op1) >= Z_STRLEN_P(op2)) {
                     longer = op1;
                     shorter = op2;
              } else {
                     longer = op2;
                     shorter = op1;
              }

              Z_TYPE_P(result) = IS_STRING;
              result_len = Z_STRLEN_P(longer);
              result_str = estrndup(Z_STRVAL_P(longer), Z_STRLEN_P(longer));
              for (i = 0; i < Z_STRLEN_P(shorter); i++) {
                     result_str[i] |= Z_STRVAL_P(shorter)[i];
              }
              if (result==op1) {
                     STR_FREE(Z_STRVAL_P(result));
              }
              Z_STRVAL_P(result) = result_str;
              Z_STRLEN_P(result) = result_len;
              return SUCCESS;
       }
       zendi_convert_to_long(op1, op1_copy, result);
       op1_lval = Z_LVAL_P(op1);
       zendi_convert_to_long(op2, op2_copy, result);

       ZVAL_LONG(result, op1_lval | Z_LVAL_P(op2));
       return SUCCESS;
}

Here is the caller graph for this function:

ZEND_API int bitwise_xor_function ( zval *  result,
zval *  op1,
zval *op2  TSRMLS_DC 
)

Definition at line 1132 of file zend_operators.c.

{
       zval op1_copy, op2_copy;
       long op1_lval;

       if (Z_TYPE_P(op1) == IS_STRING && Z_TYPE_P(op2) == IS_STRING) {
              zval *longer, *shorter;
              char *result_str;
              int i, result_len;

              if (Z_STRLEN_P(op1) >= Z_STRLEN_P(op2)) {
                     longer = op1;
                     shorter = op2;
              } else {
                     longer = op2;
                     shorter = op1;
              }

              Z_TYPE_P(result) = IS_STRING;
              result_len = Z_STRLEN_P(shorter);
              result_str = estrndup(Z_STRVAL_P(shorter), Z_STRLEN_P(shorter));
              for (i = 0; i < Z_STRLEN_P(shorter); i++) {
                     result_str[i] ^= Z_STRVAL_P(longer)[i];
              }
              if (result==op1) {
                     STR_FREE(Z_STRVAL_P(result));
              }
              Z_STRVAL_P(result) = result_str;
              Z_STRLEN_P(result) = result_len;
              return SUCCESS;
       }

       zendi_convert_to_long(op1, op1_copy, result);
       op1_lval = Z_LVAL_P(op1);
       zendi_convert_to_long(op2, op2_copy, result);

       ZVAL_LONG(result, op1_lval ^ Z_LVAL_P(op2));
       return SUCCESS;
}

Here is the caller graph for this function:

ZEND_API int boolean_not_function ( zval *  result,
zval *op1  TSRMLS_DC 
)

Definition at line 1012 of file zend_operators.c.

{
       zval op1_copy;

       zendi_convert_to_boolean(op1, op1_copy, result);
       ZVAL_BOOL(result, !Z_LVAL_P(op1));
       return SUCCESS;
}

Here is the caller graph for this function:

ZEND_API int boolean_xor_function ( zval *  result,
zval *  op1,
zval *op2  TSRMLS_DC 
)

Definition at line 999 of file zend_operators.c.

{
       zval op1_copy, op2_copy;
       long op1_lval;

       zendi_convert_to_boolean(op1, op1_copy, result);
       op1_lval = Z_LVAL_P(op1);
       zendi_convert_to_boolean(op2, op2_copy, result);
       ZVAL_BOOL(result, op1_lval ^ Z_LVAL_P(op2));
       return SUCCESS;
}

Here is the caller graph for this function:

ZEND_API int compare_function ( zval *  result,
zval *  op1,
zval *op2  TSRMLS_DC 
)

Definition at line 1376 of file zend_operators.c.

{
       int ret;
       int converted = 0;
       zval op1_copy, op2_copy;
       zval *op_free;

       while (1) {
              switch (TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2))) {
                     case TYPE_PAIR(IS_LONG, IS_LONG):
                            ZVAL_LONG(result, Z_LVAL_P(op1)>Z_LVAL_P(op2)?1:(Z_LVAL_P(op1)<Z_LVAL_P(op2)?-1:0));
                            return SUCCESS;

                     case TYPE_PAIR(IS_DOUBLE, IS_LONG):
                            Z_DVAL_P(result) = Z_DVAL_P(op1) - (double)Z_LVAL_P(op2);
                            ZVAL_LONG(result, ZEND_NORMALIZE_BOOL(Z_DVAL_P(result)));
                            return SUCCESS;

                     case TYPE_PAIR(IS_LONG, IS_DOUBLE):
                            Z_DVAL_P(result) = (double)Z_LVAL_P(op1) - Z_DVAL_P(op2);
                            ZVAL_LONG(result, ZEND_NORMALIZE_BOOL(Z_DVAL_P(result)));
                            return SUCCESS;

                     case TYPE_PAIR(IS_DOUBLE, IS_DOUBLE):
                            Z_DVAL_P(result) = Z_DVAL_P(op1) - Z_DVAL_P(op2);
                            ZVAL_LONG(result, ZEND_NORMALIZE_BOOL(Z_DVAL_P(result)));
                            return SUCCESS;

                     case TYPE_PAIR(IS_ARRAY, IS_ARRAY):
                            zend_compare_arrays(result, op1, op2 TSRMLS_CC);
                            return SUCCESS;

                     case TYPE_PAIR(IS_NULL, IS_NULL):
                            ZVAL_LONG(result, 0);
                            return SUCCESS;

                     case TYPE_PAIR(IS_NULL, IS_BOOL):
                            ZVAL_LONG(result, Z_LVAL_P(op2) ? -1 : 0);
                            return SUCCESS;

                     case TYPE_PAIR(IS_BOOL, IS_NULL):
                            ZVAL_LONG(result, Z_LVAL_P(op1) ? 1 : 0);
                            return SUCCESS;

                     case TYPE_PAIR(IS_BOOL, IS_BOOL):
                            ZVAL_LONG(result, ZEND_NORMALIZE_BOOL(Z_LVAL_P(op1) - Z_LVAL_P(op2)));
                            return SUCCESS;

                     case TYPE_PAIR(IS_STRING, IS_STRING):
                            zendi_smart_strcmp(result, op1, op2);
                            return SUCCESS;

                     case TYPE_PAIR(IS_NULL, IS_STRING):
                            ZVAL_LONG(result, zend_binary_strcmp("", 0, Z_STRVAL_P(op2), Z_STRLEN_P(op2)));
                            return SUCCESS;

                     case TYPE_PAIR(IS_STRING, IS_NULL):
                            ZVAL_LONG(result, zend_binary_strcmp(Z_STRVAL_P(op1), Z_STRLEN_P(op1), "", 0));
                            return SUCCESS;

                     case TYPE_PAIR(IS_OBJECT, IS_NULL):
                            ZVAL_LONG(result, 1);
                            return SUCCESS;

                     case TYPE_PAIR(IS_NULL, IS_OBJECT):
                            ZVAL_LONG(result, -1);
                            return SUCCESS;

                     case TYPE_PAIR(IS_OBJECT, IS_OBJECT):
                            /* If both are objects sharing the same comparision handler then use is */
                            if (Z_OBJ_HANDLER_P(op1,compare_objects) == Z_OBJ_HANDLER_P(op2,compare_objects)) {
                                   if (Z_OBJ_HANDLE_P(op1) == Z_OBJ_HANDLE_P(op2)) {
                                          /* object handles are identical, apprently this is the same object */
                                          ZVAL_LONG(result, 0);
                                          return SUCCESS;
                                   }
                                   ZVAL_LONG(result, Z_OBJ_HT_P(op1)->compare_objects(op1, op2 TSRMLS_CC));
                                   return SUCCESS;
                            }
                            /* break missing intentionally */

                     default:
                            if (Z_TYPE_P(op1) == IS_OBJECT) {
                                   if (Z_OBJ_HT_P(op1)->get) {
                                          op_free = Z_OBJ_HT_P(op1)->get(op1 TSRMLS_CC);
                                          ret = compare_function(result, op_free, op2 TSRMLS_CC);
                                          zend_free_obj_get_result(op_free TSRMLS_CC);
                                          return ret;
                                   } else if (Z_TYPE_P(op2) != IS_OBJECT && Z_OBJ_HT_P(op1)->cast_object) {
                                          ALLOC_INIT_ZVAL(op_free);
                                          if (Z_OBJ_HT_P(op1)->cast_object(op1, op_free, Z_TYPE_P(op2) TSRMLS_CC) == FAILURE) {
                                                 ZVAL_LONG(result, 1);
                                                 zend_free_obj_get_result(op_free TSRMLS_CC);
                                                 return SUCCESS;
                                          }
                                          ret = compare_function(result, op_free, op2 TSRMLS_CC);
                                          zend_free_obj_get_result(op_free TSRMLS_CC);
                                          return ret;
                                   }
                            }
                            if (Z_TYPE_P(op2) == IS_OBJECT) {
                                   if (Z_OBJ_HT_P(op2)->get) {
                                          op_free = Z_OBJ_HT_P(op2)->get(op2 TSRMLS_CC);
                                          ret = compare_function(result, op1, op_free TSRMLS_CC);
                                          zend_free_obj_get_result(op_free TSRMLS_CC);
                                          return ret;
                                   } else if (Z_TYPE_P(op1) != IS_OBJECT && Z_OBJ_HT_P(op2)->cast_object) {
                                          ALLOC_INIT_ZVAL(op_free);
                                          if (Z_OBJ_HT_P(op2)->cast_object(op2, op_free, Z_TYPE_P(op1) TSRMLS_CC) == FAILURE) {
                                                 ZVAL_LONG(result, -1);
                                                 zend_free_obj_get_result(op_free TSRMLS_CC);
                                                 return SUCCESS;
                                          }
                                          ret = compare_function(result, op1, op_free TSRMLS_CC);
                                          zend_free_obj_get_result(op_free TSRMLS_CC);
                                          return ret;
                                   }
                            }
                            if (!converted) {
                                   if (Z_TYPE_P(op1) == IS_NULL) {
                                          zendi_convert_to_boolean(op2, op2_copy, result);
                                          ZVAL_LONG(result, Z_LVAL_P(op2) ? -1 : 0);
                                          return SUCCESS;
                                   } else if (Z_TYPE_P(op2) == IS_NULL) {
                                          zendi_convert_to_boolean(op1, op1_copy, result);
                                          ZVAL_LONG(result, Z_LVAL_P(op1) ? 1 : 0);
                                          return SUCCESS;
                                   } else if (Z_TYPE_P(op1) == IS_BOOL) {
                                          zendi_convert_to_boolean(op2, op2_copy, result);
                                          ZVAL_LONG(result, ZEND_NORMALIZE_BOOL(Z_LVAL_P(op1) - Z_LVAL_P(op2)));
                                          return SUCCESS;
                                   } else if (Z_TYPE_P(op2) == IS_BOOL) {
                                          zendi_convert_to_boolean(op1, op1_copy, result);
                                          ZVAL_LONG(result, ZEND_NORMALIZE_BOOL(Z_LVAL_P(op1) - Z_LVAL_P(op2)));
                                          return SUCCESS;
                                   } else {
                                          zendi_convert_scalar_to_number(op1, op1_copy, result);
                                          zendi_convert_scalar_to_number(op2, op2_copy, result);
                                          converted = 1;
                                   }
                            } else if (Z_TYPE_P(op1)==IS_ARRAY) {
                                   ZVAL_LONG(result, 1);
                                   return SUCCESS;
                            } else if (Z_TYPE_P(op2)==IS_ARRAY) {
                                   ZVAL_LONG(result, -1);
                                   return SUCCESS;
                            } else if (Z_TYPE_P(op1)==IS_OBJECT) {
                                   ZVAL_LONG(result, 1);
                                   return SUCCESS;
                            } else if (Z_TYPE_P(op2)==IS_OBJECT) {
                                   ZVAL_LONG(result, -1);
                                   return SUCCESS;
                            } else {
                                   ZVAL_LONG(result, 0);
                                   return FAILURE;
                            }
              }
       }
}

Here is the call graph for this function:

ZEND_API int concat_function ( zval *  result,
zval *  op1,
zval *op2  TSRMLS_DC 
)

Definition at line 1225 of file zend_operators.c.

{
       zval op1_copy, op2_copy;
       int use_copy1 = 0, use_copy2 = 0;

       if (Z_TYPE_P(op1) != IS_STRING) {
              zend_make_printable_zval(op1, &op1_copy, &use_copy1);
       }
       if (Z_TYPE_P(op2) != IS_STRING) {
              zend_make_printable_zval(op2, &op2_copy, &use_copy2);
       }

       if (use_copy1) {
              /* We have created a converted copy of op1. Therefore, op1 won't become the result so
               * we have to free it.
               */
              if (result == op1) {
                     zval_dtor(op1);
              }
              op1 = &op1_copy;
       }
       if (use_copy2) {
              op2 = &op2_copy;
       }
       if (result==op1) {   /* special case, perform operations on result */
              uint res_len = Z_STRLEN_P(op1) + Z_STRLEN_P(op2);

              if (Z_STRLEN_P(result) < 0 || (int) (Z_STRLEN_P(op1) + Z_STRLEN_P(op2)) < 0) {
                     efree(Z_STRVAL_P(result));
                     ZVAL_EMPTY_STRING(result);
                     zend_error(E_ERROR, "String size overflow");
              }

              Z_STRVAL_P(result) = erealloc(Z_STRVAL_P(result), res_len+1);

              memcpy(Z_STRVAL_P(result)+Z_STRLEN_P(result), Z_STRVAL_P(op2), Z_STRLEN_P(op2));
              Z_STRVAL_P(result)[res_len]=0;
              Z_STRLEN_P(result) = res_len;
       } else {
              Z_STRLEN_P(result) = Z_STRLEN_P(op1) + Z_STRLEN_P(op2);
              Z_STRVAL_P(result) = (char *) emalloc(Z_STRLEN_P(result) + 1);
              memcpy(Z_STRVAL_P(result), Z_STRVAL_P(op1), Z_STRLEN_P(op1));
              memcpy(Z_STRVAL_P(result)+Z_STRLEN_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op2));
              Z_STRVAL_P(result)[Z_STRLEN_P(result)] = 0;
              Z_TYPE_P(result) = IS_STRING;
       }
       if (use_copy1) {
              zval_dtor(op1);
       }
       if (use_copy2) {
              zval_dtor(op2);
       }
       return SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API void convert_scalar_to_number ( zval *op  TSRMLS_DC)

Definition at line 150 of file zend_operators.c.

{
       switch (Z_TYPE_P(op)) {
              case IS_STRING:
                     {
                            char *strval;

                            strval = Z_STRVAL_P(op);
                            if ((Z_TYPE_P(op)=is_numeric_string(strval, Z_STRLEN_P(op), &Z_LVAL_P(op), &Z_DVAL_P(op), 1)) == 0) {
                                   ZVAL_LONG(op, 0);
                            }
                            STR_FREE(strval);
                            break;
                     }
              case IS_BOOL:
                     Z_TYPE_P(op) = IS_LONG;
                     break;
              case IS_RESOURCE:
                     zend_list_delete(Z_LVAL_P(op));
                     Z_TYPE_P(op) = IS_LONG;
                     break;
              case IS_OBJECT:
                     convert_to_long_base(op, 10);
                     break;
              case IS_NULL:
                     ZVAL_LONG(op, 0);
                     break;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API void convert_to_array ( zval *  op)

Definition at line 635 of file zend_operators.c.

{
       TSRMLS_FETCH();

       switch (Z_TYPE_P(op)) {
              case IS_ARRAY:
                     break;
/* OBJECTS_OPTIMIZE */
              case IS_OBJECT:
                     {
                            zval *tmp;
                            HashTable *ht;

                            ALLOC_HASHTABLE(ht);
                            zend_hash_init(ht, 0, NULL, ZVAL_PTR_DTOR, 0);
                            if (Z_OBJCE_P(op) == zend_ce_closure) {
                                   convert_scalar_to_array(op, IS_ARRAY TSRMLS_CC);
                                   if (Z_TYPE_P(op) == IS_ARRAY) {
                                          zend_hash_destroy(ht);
                                          FREE_HASHTABLE(ht);
                                          return;
                                   }
                            } else if (Z_OBJ_HT_P(op)->get_properties) {
                                   HashTable *obj_ht = Z_OBJ_HT_P(op)->get_properties(op TSRMLS_CC);
                                   if (obj_ht) {
                                          zend_hash_copy(ht, obj_ht, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
                                   }
                            } else {
                                   convert_object_to_type(op, IS_ARRAY, convert_to_array);

                                   if (Z_TYPE_P(op) == IS_ARRAY) {
                                          zend_hash_destroy(ht);
                                          FREE_HASHTABLE(ht);
                                          return;
                                   }
                            }
                            zval_dtor(op);
                            Z_TYPE_P(op) = IS_ARRAY;
                            Z_ARRVAL_P(op) = ht;
                     }
                     break;
              case IS_NULL:
                     ALLOC_HASHTABLE(Z_ARRVAL_P(op));
                     zend_hash_init(Z_ARRVAL_P(op), 0, NULL, ZVAL_PTR_DTOR, 0);
                     Z_TYPE_P(op) = IS_ARRAY;
                     break;
              default:
                     convert_scalar_to_array(op, IS_ARRAY TSRMLS_CC);
                     break;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API void convert_to_boolean ( zval *  op)

Definition at line 477 of file zend_operators.c.

{
       int tmp;

       switch (Z_TYPE_P(op)) {
              case IS_BOOL:
                     break;
              case IS_NULL:
                     Z_LVAL_P(op) = 0;
                     break;
              case IS_RESOURCE: {
                            TSRMLS_FETCH();

                            zend_list_delete(Z_LVAL_P(op));
                     }
                     /* break missing intentionally */
              case IS_LONG:
                     Z_LVAL_P(op) = (Z_LVAL_P(op) ? 1 : 0);
                     break;
              case IS_DOUBLE:
                     Z_LVAL_P(op) = (Z_DVAL_P(op) ? 1 : 0);
                     break;
              case IS_STRING:
                     {
                            char *strval = Z_STRVAL_P(op);

                            if (Z_STRLEN_P(op) == 0
                                   || (Z_STRLEN_P(op)==1 && Z_STRVAL_P(op)[0]=='0')) {
                                   Z_LVAL_P(op) = 0;
                            } else {
                                   Z_LVAL_P(op) = 1;
                            }
                            STR_FREE(strval);
                     }
                     break;
              case IS_ARRAY:
                     tmp = (zend_hash_num_elements(Z_ARRVAL_P(op))?1:0);
                     zval_dtor(op);
                     Z_LVAL_P(op) = tmp;
                     break;
              case IS_OBJECT:
                     {
                            zend_bool retval = 1;
                            TSRMLS_FETCH();

                            convert_object_to_type(op, IS_BOOL, convert_to_boolean);

                            if (Z_TYPE_P(op) == IS_BOOL) {
                                   return;
                            }

                            zval_dtor(op);
                            ZVAL_BOOL(op, retval);
                            break;
                     }
              default:
                     zval_dtor(op);
                     Z_LVAL_P(op) = 0;
                     break;
       }
       Z_TYPE_P(op) = IS_BOOL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API void convert_to_double ( zval *  op)

Definition at line 395 of file zend_operators.c.

{
       double tmp;

       switch (Z_TYPE_P(op)) {
              case IS_NULL:
                     Z_DVAL_P(op) = 0.0;
                     break;
              case IS_RESOURCE: {
                            TSRMLS_FETCH();

                            zend_list_delete(Z_LVAL_P(op));
                     }
                     /* break missing intentionally */
              case IS_BOOL:
              case IS_LONG:
                     Z_DVAL_P(op) = (double) Z_LVAL_P(op);
                     break;
              case IS_DOUBLE:
                     break;
              case IS_STRING:
                     {
                            char *strval = Z_STRVAL_P(op);

                            Z_DVAL_P(op) = zend_strtod(strval, NULL);
                            STR_FREE(strval);
                     }
                     break;
              case IS_ARRAY:
                     tmp = (zend_hash_num_elements(Z_ARRVAL_P(op))?1:0);
                     zval_dtor(op);
                     Z_DVAL_P(op) = tmp;
                     break;
              case IS_OBJECT:
                     {
                            double retval = 1.0;
                            TSRMLS_FETCH();

                            convert_object_to_type(op, IS_DOUBLE, convert_to_double);

                            if (Z_TYPE_P(op) == IS_DOUBLE) {
                                   return;
                            }
                            zend_error(E_NOTICE, "Object of class %s could not be converted to double", Z_OBJCE_P(op)->name);

                            zval_dtor(op);
                            ZVAL_DOUBLE(op, retval);
                            break;
                     }
              default:
                     zend_error(E_WARNING, "Cannot convert to real value (type=%d)", Z_TYPE_P(op));
                     zval_dtor(op);
                     Z_DVAL_P(op) = 0;
                     break;
       }
       Z_TYPE_P(op) = IS_DOUBLE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API void convert_to_long ( zval *  op)

Definition at line 327 of file zend_operators.c.

{
       if (Z_TYPE_P(op) != IS_LONG) {
              convert_to_long_base(op, 10);
       }
}

Here is the call graph for this function:

ZEND_API void convert_to_long_base ( zval *  op,
int  base 
)

Definition at line 335 of file zend_operators.c.

{
       long tmp;

       switch (Z_TYPE_P(op)) {
              case IS_NULL:
                     Z_LVAL_P(op) = 0;
                     break;
              case IS_RESOURCE: {
                            TSRMLS_FETCH();

                            zend_list_delete(Z_LVAL_P(op));
                     }
                     /* break missing intentionally */
              case IS_BOOL:
              case IS_LONG:
                     break;
              case IS_DOUBLE:
                     Z_LVAL_P(op) = zend_dval_to_lval(Z_DVAL_P(op));
                     break;
              case IS_STRING:
                     {
                            char *strval = Z_STRVAL_P(op);

                            Z_LVAL_P(op) = strtol(strval, NULL, base);
                            STR_FREE(strval);
                     }
                     break;
              case IS_ARRAY:
                     tmp = (zend_hash_num_elements(Z_ARRVAL_P(op))?1:0);
                     zval_dtor(op);
                     Z_LVAL_P(op) = tmp;
                     break;
              case IS_OBJECT:
                     {
                            int retval = 1;
                            TSRMLS_FETCH();

                            convert_object_to_type(op, IS_LONG, convert_to_long);

                            if (Z_TYPE_P(op) == IS_LONG) {
                                   return;
                            }
                            zend_error(E_NOTICE, "Object of class %s could not be converted to int", Z_OBJCE_P(op)->name);

                            zval_dtor(op);
                            ZVAL_LONG(op, retval);
                            return;
                     }
              default:
                     zend_error(E_WARNING, "Cannot convert to ordinal value");
                     zval_dtor(op);
                     Z_LVAL_P(op) = 0;
                     break;
       }

       Z_TYPE_P(op) = IS_LONG;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API void convert_to_null ( zval *  op)

Definition at line 454 of file zend_operators.c.

{
       if (Z_TYPE_P(op) == IS_OBJECT) {
              if (Z_OBJ_HT_P(op)->cast_object) {
                     zval *org;
                     TSRMLS_FETCH();

                     ALLOC_ZVAL(org);
                     *org = *op;
                     if (Z_OBJ_HT_P(op)->cast_object(org, op, IS_NULL TSRMLS_CC) == SUCCESS) {
                            zval_dtor(org);
                            return;
                     }
                     *op = *org;
                     FREE_ZVAL(org);
              }
       }

       zval_dtor(op);
       Z_TYPE_P(op) = IS_NULL;
}

Here is the caller graph for this function:

ZEND_API void convert_to_object ( zval *  op)

Definition at line 688 of file zend_operators.c.

{
       TSRMLS_FETCH();

       switch (Z_TYPE_P(op)) {
              case IS_ARRAY:
                     {
                            object_and_properties_init(op, zend_standard_class_def, Z_ARRVAL_P(op));
                            break;
                     }
              case IS_OBJECT:
                     break;
              case IS_NULL:
                     object_init(op);
                     break;
              default:
                     convert_scalar_to_array(op, IS_OBJECT TSRMLS_CC);
                     break;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API int decrement_function ( zval *  op2)

Definition at line 1805 of file zend_operators.c.

{
       long lval;
       double dval;

       switch (Z_TYPE_P(op1)) {
              case IS_LONG:
                     if (Z_LVAL_P(op1) == LONG_MIN) {
                            double d = (double)Z_LVAL_P(op1);
                            ZVAL_DOUBLE(op1, d-1);
                     } else {
                     Z_LVAL_P(op1)--;
                     }
                     break;
              case IS_DOUBLE:
                     Z_DVAL_P(op1) = Z_DVAL_P(op1) - 1;
                     break;
              case IS_STRING:             /* Like perl we only support string increment */
                     if (Z_STRLEN_P(op1) == 0) { /* consider as 0 */
                            STR_FREE(Z_STRVAL_P(op1));
                            ZVAL_LONG(op1, -1);
                            break;
                     }
                     switch (is_numeric_string(Z_STRVAL_P(op1), Z_STRLEN_P(op1), &lval, &dval, 0)) {
                            case IS_LONG:
                                   STR_FREE(Z_STRVAL_P(op1));
                                   if (lval == LONG_MIN) {
                                          double d = (double)lval;
                                          ZVAL_DOUBLE(op1, d-1);
                                   } else {
                                          ZVAL_LONG(op1, lval-1);
                                   }
                                   break;
                            case IS_DOUBLE:
                                   STR_FREE(Z_STRVAL_P(op1));
                                   ZVAL_DOUBLE(op1, dval - 1);
                                   break;
                     }
                     break;
              default:
                     return FAILURE;
       }

       return SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API int div_function ( zval *  result,
zval *  op1,
zval *op2  TSRMLS_DC 
)

Definition at line 908 of file zend_operators.c.

{
       zval op1_copy, op2_copy;
       int converted = 0;

       while (1) {
              switch (TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2))) {
                     case TYPE_PAIR(IS_LONG, IS_LONG):
                            if (Z_LVAL_P(op2) == 0) {
                                   zend_error(E_WARNING, "Division by zero");
                                   ZVAL_BOOL(result, 0);
                                   return FAILURE;                    /* division by zero */
                            } else if (Z_LVAL_P(op2) == -1 && Z_LVAL_P(op1) == LONG_MIN) {
                                   /* Prevent overflow error/crash */
                                   ZVAL_DOUBLE(result, (double) LONG_MIN / -1);
                                   return SUCCESS;
                            }
                            if (Z_LVAL_P(op1) % Z_LVAL_P(op2) == 0) { /* integer */
                                   ZVAL_LONG(result, Z_LVAL_P(op1) / Z_LVAL_P(op2));
                            } else {
                                   ZVAL_DOUBLE(result, ((double) Z_LVAL_P(op1)) / Z_LVAL_P(op2));
                            }
                            return SUCCESS;

                     case TYPE_PAIR(IS_DOUBLE, IS_LONG):
                            if (Z_LVAL_P(op2) == 0) {
                                   zend_error(E_WARNING, "Division by zero");
                                   ZVAL_BOOL(result, 0);
                                   return FAILURE;                    /* division by zero */
                            }
                            ZVAL_DOUBLE(result, Z_DVAL_P(op1) / (double)Z_LVAL_P(op2));
                            return SUCCESS;

                     case TYPE_PAIR(IS_LONG, IS_DOUBLE):
                            if (Z_DVAL_P(op2) == 0) {
                                   zend_error(E_WARNING, "Division by zero");
                                   ZVAL_BOOL(result, 0);
                                   return FAILURE;                    /* division by zero */
                            }
                            ZVAL_DOUBLE(result, (double)Z_LVAL_P(op1) / Z_DVAL_P(op2));
                            return SUCCESS;

                     case TYPE_PAIR(IS_DOUBLE, IS_DOUBLE):
                            if (Z_DVAL_P(op2) == 0) {
                                   zend_error(E_WARNING, "Division by zero");
                                   ZVAL_BOOL(result, 0);
                                   return FAILURE;                    /* division by zero */
                            }
                            ZVAL_DOUBLE(result, Z_DVAL_P(op1) / Z_DVAL_P(op2));
                            return SUCCESS;

                     default:
                            if (!converted) {
                                   zendi_convert_scalar_to_number(op1, op1_copy, result);
                                   zendi_convert_scalar_to_number(op2, op2_copy, result);
                                   converted = 1;
                            } else {
                                   zend_error(E_ERROR, "Unsupported operand types");
                                   return FAILURE; /* unknown datatype */
                            }
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API int increment_function ( zval *  op1)

Definition at line 1754 of file zend_operators.c.

{
       switch (Z_TYPE_P(op1)) {
              case IS_LONG:
                     if (Z_LVAL_P(op1) == LONG_MAX) {
                            /* switch to double */
                            double d = (double)Z_LVAL_P(op1);
                            ZVAL_DOUBLE(op1, d+1);
                     } else {
                     Z_LVAL_P(op1)++;
                     }
                     break;
              case IS_DOUBLE:
                     Z_DVAL_P(op1) = Z_DVAL_P(op1) + 1;
                     break;
              case IS_NULL:
                     ZVAL_LONG(op1, 1);
                     break;
              case IS_STRING: {
                            long lval;
                            double dval;

                            switch (is_numeric_string(Z_STRVAL_P(op1), Z_STRLEN_P(op1), &lval, &dval, 0)) {
                                   case IS_LONG:
                                          efree(Z_STRVAL_P(op1));
                                          if (lval == LONG_MAX) {
                                                 /* switch to double */
                                                 double d = (double)lval;
                                                 ZVAL_DOUBLE(op1, d+1);
                                          } else {
                                                 ZVAL_LONG(op1, lval+1);
                                          }
                                          break;
                                   case IS_DOUBLE:
                                          efree(Z_STRVAL_P(op1));
                                          ZVAL_DOUBLE(op1, dval+1);
                                          break;
                                   default:
                                          /* Perl style string increment */
                                          increment_string(op1);
                                          break;
                            }
                     }
                     break;
              default:
                     return FAILURE;
       }
       return SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API zend_bool instanceof_function ( const zend_class_entry *  instance_ce,
const zend_class_entry *ce  TSRMLS_DC 
)

Definition at line 1667 of file zend_operators.c.

{
       return instanceof_function_ex(instance_ce, ce, 0 TSRMLS_CC);
}

Here is the call graph for this function:

ZEND_API zend_bool instanceof_function_ex ( const zend_class_entry *  instance_ce,
const zend_class_entry *  ce,
zend_bool interfaces_only  TSRMLS_DC 
)

Definition at line 1645 of file zend_operators.c.

{
       zend_uint i;

       for (i=0; i<instance_ce->num_interfaces; i++) {
              if (instanceof_function(instance_ce->interfaces[i], ce TSRMLS_CC)) {
                     return 1;
              }
       }
       if (!interfaces_only) {
              while (instance_ce) {
                     if (instance_ce == ce) {
                            return 1;
                     }
                     instance_ce = instance_ce->parent;
              }
       }

       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API int is_equal_function ( zval *  result,
zval *  op1,
zval *op2  TSRMLS_DC 
)

Definition at line 1605 of file zend_operators.c.

{
       if (compare_function(result, op1, op2 TSRMLS_CC) == FAILURE) {
              return FAILURE;
       }
       ZVAL_BOOL(result, (Z_LVAL_P(result) == 0));
       return SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API int is_identical_function ( zval *  result,
zval *  op1,
zval *op2  TSRMLS_DC 
)

Definition at line 1554 of file zend_operators.c.

{
       Z_TYPE_P(result) = IS_BOOL;
       if (Z_TYPE_P(op1) != Z_TYPE_P(op2)) {
              Z_LVAL_P(result) = 0;
              return SUCCESS;
       }
       switch (Z_TYPE_P(op1)) {
              case IS_NULL:
                     Z_LVAL_P(result) = 1;
                     break;
              case IS_BOOL:
              case IS_LONG:
              case IS_RESOURCE:
                     Z_LVAL_P(result) = (Z_LVAL_P(op1) == Z_LVAL_P(op2));
                     break;
              case IS_DOUBLE:
                     Z_LVAL_P(result) = (Z_DVAL_P(op1) == Z_DVAL_P(op2));
                     break;
              case IS_STRING:
                     Z_LVAL_P(result) = ((Z_STRLEN_P(op1) == Z_STRLEN_P(op2))
                            && (!memcmp(Z_STRVAL_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op1))));
                     break;
              case IS_ARRAY:
                     Z_LVAL_P(result) = zend_hash_compare(Z_ARRVAL_P(op1), Z_ARRVAL_P(op2), (compare_func_t) hash_zval_identical_function, 1 TSRMLS_CC)==0;
                     break;
              case IS_OBJECT:
                     if (Z_OBJ_HT_P(op1) == Z_OBJ_HT_P(op2)) {
                            Z_LVAL_P(result) = (Z_OBJ_HANDLE_P(op1) == Z_OBJ_HANDLE_P(op2));
                     } else {
                            Z_LVAL_P(result) = 0;
                     }
                     break;
              default:
                     Z_LVAL_P(result) = 0;
                     return FAILURE;
       }
       return SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API int is_not_equal_function ( zval *  result,
zval *  op1,
zval *op2  TSRMLS_DC 
)

Definition at line 1615 of file zend_operators.c.

{
       if (compare_function(result, op1, op2 TSRMLS_CC) == FAILURE) {
              return FAILURE;
       }
       ZVAL_BOOL(result, (Z_LVAL_P(result) != 0));
       return SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API int is_not_identical_function ( zval *  result,
zval *  op1,
zval *op2  TSRMLS_DC 
)

Definition at line 1595 of file zend_operators.c.

{
       if (is_identical_function(result, op1, op2 TSRMLS_CC) == FAILURE) {
              return FAILURE;
       }
       Z_LVAL_P(result) = !Z_LVAL_P(result);
       return SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static zend_uchar is_numeric_string ( const char *  str,
int  length,
long *  lval,
double *  dval,
int  allow_errors 
) [inline, static]

Checks whether the string "str" with length "length" is numeric.

The value of allow_errors determines whether it's required to be entirely numeric, or just its prefix. Leading whitespace is allowed.

The function returns 0 if the string did not contain a valid number; IS_LONG if it contained a number that fits within the range of a long; or IS_DOUBLE if the number was out of long range or contained a decimal point/exponent. The number's value is returned into the respective pointer, *lval or *dval, if that pointer is not NULL.

Definition at line 102 of file zend_operators.h.

{
       const char *ptr;
       int base = 10, digits = 0, dp_or_e = 0;
       double local_dval;
       zend_uchar type;

       if (!length) {
              return 0;
       }

       /* Skip any whitespace
        * This is much faster than the isspace() function */
       while (*str == ' ' || *str == '\t' || *str == '\n' || *str == '\r' || *str == '\v' || *str == '\f') {
              str++;
              length--;
       }
       ptr = str;

       if (*ptr == '-' || *ptr == '+') {
              ptr++;
       }

       if (ZEND_IS_DIGIT(*ptr)) {
              /* Handle hex numbers
               * str is used instead of ptr to disallow signs and keep old behavior */
              if (length > 2 && *str == '0' && (str[1] == 'x' || str[1] == 'X')) {
                     base = 16;
                     ptr += 2;
              }

              /* Skip any leading 0s */
              while (*ptr == '0') {
                     ptr++;
              }

              /* Count the number of digits. If a decimal point/exponent is found,
               * it's a double. Otherwise, if there's a dval or no need to check for
               * a full match, stop when there are too many digits for a long */
              for (type = IS_LONG; !(digits >= MAX_LENGTH_OF_LONG && (dval || allow_errors == 1)); digits++, ptr++) {
check_digits:
                     if (ZEND_IS_DIGIT(*ptr) || (base == 16 && ZEND_IS_XDIGIT(*ptr))) {
                            continue;
                     } else if (base == 10) {
                            if (*ptr == '.' && dp_or_e < 1) {
                                   goto process_double;
                            } else if ((*ptr == 'e' || *ptr == 'E') && dp_or_e < 2) {
                                   const char *e = ptr + 1;

                                   if (*e == '-' || *e == '+') {
                                          ptr = e++;
                                   }
                                   if (ZEND_IS_DIGIT(*e)) {
                                          goto process_double;
                                   }
                            }
                     }

                     break;
              }

              if (base == 10) {
                     if (digits >= MAX_LENGTH_OF_LONG) {
                            dp_or_e = -1;
                            goto process_double;
                     }
              } else if (!(digits < SIZEOF_LONG * 2 || (digits == SIZEOF_LONG * 2 && ptr[-digits] <= '7'))) {
                     if (dval) {
                            local_dval = zend_hex_strtod(str, (char **)&ptr);
                     }
                     type = IS_DOUBLE;
              }
       } else if (*ptr == '.' && ZEND_IS_DIGIT(ptr[1])) {
process_double:
              type = IS_DOUBLE;

              /* If there's a dval, do the conversion; else continue checking
               * the digits if we need to check for a full match */
              if (dval) {
                     local_dval = zend_strtod(str, (char **)&ptr);
              } else if (allow_errors != 1 && dp_or_e != -1) {
                     dp_or_e = (*ptr++ == '.') ? 1 : 2;
                     goto check_digits;
              }
       } else {
              return 0;
       }

       if (ptr != str + length) {
              if (!allow_errors) {
                     return 0;
              }
              if (allow_errors == -1) {
                     zend_error(E_NOTICE, "A non well formed numeric value encountered");
              }
       }

       if (type == IS_LONG) {
              if (digits == MAX_LENGTH_OF_LONG - 1) {
                     int cmp = strcmp(&ptr[-digits], long_min_digits);

                     if (!(cmp < 0 || (cmp == 0 && *str == '-'))) {
                            if (dval) {
                                   *dval = zend_strtod(str, NULL);
                            }

                            return IS_DOUBLE;
                     }
              }

              if (lval) {
                     *lval = strtol(str, NULL, base);
              }

              return IS_LONG;
       } else {
              if (dval) {
                     *dval = local_dval;
              }

              return IS_DOUBLE;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API int is_smaller_function ( zval *  result,
zval *  op1,
zval *op2  TSRMLS_DC 
)

Definition at line 1625 of file zend_operators.c.

{
       if (compare_function(result, op1, op2 TSRMLS_CC) == FAILURE) {
              return FAILURE;
       }
       ZVAL_BOOL(result, (Z_LVAL_P(result) < 0));
       return SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API int is_smaller_or_equal_function ( zval *  result,
zval *  op1,
zval *op2  TSRMLS_DC 
)

Definition at line 1635 of file zend_operators.c.

{
       if (compare_function(result, op1, op2 TSRMLS_CC) == FAILURE) {
              return FAILURE;
       }
       ZVAL_BOOL(result, (Z_LVAL_P(result) <= 0));
       return SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API int mod_function ( zval *  result,
zval *  op1,
zval *op2  TSRMLS_DC 
)

Definition at line 973 of file zend_operators.c.

{
       zval op1_copy, op2_copy;
       long op1_lval;

       zendi_convert_to_long(op1, op1_copy, result);
       op1_lval = Z_LVAL_P(op1);
       zendi_convert_to_long(op2, op2_copy, result);

       if (Z_LVAL_P(op2) == 0) {
              zend_error(E_WARNING, "Division by zero");
              ZVAL_BOOL(result, 0);
              return FAILURE;                    /* modulus by zero */
       }

       if (Z_LVAL_P(op2) == -1) {
              /* Prevent overflow error/crash if op1==LONG_MIN */
              ZVAL_LONG(result, 0);
              return SUCCESS;
       }

       ZVAL_LONG(result, op1_lval % Z_LVAL_P(op2));
       return SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API int mul_function ( zval *  result,
zval *  op1,
zval *op2  TSRMLS_DC 
)

Definition at line 867 of file zend_operators.c.

{
       zval op1_copy, op2_copy;
       int converted = 0;

       while (1) {
              switch (TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2))) {
                     case TYPE_PAIR(IS_LONG, IS_LONG): {
                            long overflow;

                            ZEND_SIGNED_MULTIPLY_LONG(Z_LVAL_P(op1),Z_LVAL_P(op2), Z_LVAL_P(result),Z_DVAL_P(result),overflow);
                            Z_TYPE_P(result) = overflow ? IS_DOUBLE : IS_LONG;
                            return SUCCESS;

                     }
                     case TYPE_PAIR(IS_LONG, IS_DOUBLE):
                            ZVAL_DOUBLE(result, ((double)Z_LVAL_P(op1)) * Z_DVAL_P(op2));
                            return SUCCESS;

                     case TYPE_PAIR(IS_DOUBLE, IS_LONG):
                            ZVAL_DOUBLE(result, Z_DVAL_P(op1) * ((double)Z_LVAL_P(op2)));
                            return SUCCESS;

                     case TYPE_PAIR(IS_DOUBLE, IS_DOUBLE):
                            ZVAL_DOUBLE(result, Z_DVAL_P(op1) * Z_DVAL_P(op2));
                            return SUCCESS;

                     default:
                            if (!converted) {
                                   zendi_convert_scalar_to_number(op1, op1_copy, result);
                                   zendi_convert_scalar_to_number(op2, op2_copy, result);
                                   converted = 1;
                            } else {
                                   zend_error(E_ERROR, "Unsupported operand types");
                                   return FAILURE; /* unknown datatype */
                            }
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API void multi_convert_to_double_ex ( int  argc,
  ... 
)

Definition at line 726 of file zend_operators.c.

{
       zval **arg;
       va_list ap;

       va_start(ap, argc);

       while (argc--) {
              arg = va_arg(ap, zval **);
              convert_to_double_ex(arg);
       }

       va_end(ap);
}
ZEND_API void multi_convert_to_long_ex ( int  argc,
  ... 
)

Definition at line 710 of file zend_operators.c.

{
       zval **arg;
       va_list ap;

       va_start(ap, argc);

       while (argc--) {
              arg = va_arg(ap, zval **);
              convert_to_long_ex(arg);
       }

       va_end(ap);
}
ZEND_API void multi_convert_to_string_ex ( int  argc,
  ... 
)

Definition at line 742 of file zend_operators.c.

{
       zval **arg;
       va_list ap;

       va_start(ap, argc);

       while (argc--) {
              arg = va_arg(ap, zval **);
              convert_to_string_ex(arg);
       }

       va_end(ap);
}
ZEND_API int numeric_compare_function ( zval *  result,
zval *  op1,
zval *op2  TSRMLS_DC 
)

Definition at line 1345 of file zend_operators.c.

{
       zval op1_copy, op2_copy;

       op1_copy = *op1;
       zval_copy_ctor(&op1_copy);

       op2_copy = *op2;
       zval_copy_ctor(&op2_copy);

       convert_to_double(&op1_copy);
       convert_to_double(&op2_copy);

       ZVAL_LONG(result, ZEND_NORMALIZE_BOOL(Z_DVAL(op1_copy)-Z_DVAL(op2_copy)));

       return SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API int shift_left_function ( zval *  result,
zval *  op1,
zval *op2  TSRMLS_DC 
)

Definition at line 1173 of file zend_operators.c.

{
       zval op1_copy, op2_copy;
       long op1_lval;

       zendi_convert_to_long(op1, op1_copy, result);
       op1_lval = Z_LVAL_P(op1);
       zendi_convert_to_long(op2, op2_copy, result);
       ZVAL_LONG(result, op1_lval << Z_LVAL_P(op2));
       return SUCCESS;
}

Here is the caller graph for this function:

ZEND_API int shift_right_function ( zval *  result,
zval *  op1,
zval *op2  TSRMLS_DC 
)

Definition at line 1186 of file zend_operators.c.

{
       zval op1_copy, op2_copy;
       long op1_lval;

       zendi_convert_to_long(op1, op1_copy, result);
       op1_lval = Z_LVAL_P(op1);
       zendi_convert_to_long(op2, op2_copy, result);
       ZVAL_LONG(result, op1_lval >> Z_LVAL_P(op2));
       return SUCCESS;
}

Here is the caller graph for this function:

ZEND_API int string_compare_function ( zval *  result,
zval *  op1,
zval *op2  TSRMLS_DC 
)

Definition at line 1281 of file zend_operators.c.

{
       zval op1_copy, op2_copy;
       int use_copy1 = 0, use_copy2 = 0;

       if (Z_TYPE_P(op1) != IS_STRING) {
              zend_make_printable_zval(op1, &op1_copy, &use_copy1);
       }
       if (Z_TYPE_P(op2) != IS_STRING) {
              zend_make_printable_zval(op2, &op2_copy, &use_copy2);
       }

       if (use_copy1) {
              op1 = &op1_copy;
       }
       if (use_copy2) {
              op2 = &op2_copy;
       }

       ZVAL_LONG(result, zend_binary_zval_strcmp(op1, op2));

       if (use_copy1) {
              zval_dtor(op1);
       }
       if (use_copy2) {
              zval_dtor(op2);
       }
       return SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API int sub_function ( zval *  result,
zval *  op1,
zval *op2  TSRMLS_DC 
)

Definition at line 820 of file zend_operators.c.

{
       zval op1_copy, op2_copy;
       int converted = 0;

       while (1) {
              switch (TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2))) {
                     case TYPE_PAIR(IS_LONG, IS_LONG): {
                            long lval = Z_LVAL_P(op1) - Z_LVAL_P(op2);

                            /* check for overflow by comparing sign bits */
                            if ((Z_LVAL_P(op1) & LONG_SIGN_MASK) != (Z_LVAL_P(op2) & LONG_SIGN_MASK)
                                   && (Z_LVAL_P(op1) & LONG_SIGN_MASK) != (lval & LONG_SIGN_MASK)) {

                                   ZVAL_DOUBLE(result, (double) Z_LVAL_P(op1) - (double) Z_LVAL_P(op2));
                            } else {
                                   ZVAL_LONG(result, lval);
                            }
                            return SUCCESS;

                     }
                     case TYPE_PAIR(IS_LONG, IS_DOUBLE):
                            ZVAL_DOUBLE(result, ((double)Z_LVAL_P(op1)) - Z_DVAL_P(op2));
                            return SUCCESS;

                     case TYPE_PAIR(IS_DOUBLE, IS_LONG):
                            ZVAL_DOUBLE(result, Z_DVAL_P(op1) - ((double)Z_LVAL_P(op2)));
                            return SUCCESS;

                     case TYPE_PAIR(IS_DOUBLE, IS_DOUBLE):
                            ZVAL_DOUBLE(result, Z_DVAL_P(op1) - Z_DVAL_P(op2));
                            return SUCCESS;

                     default:
                            if (!converted) {
                                   zendi_convert_scalar_to_number(op1, op1_copy, result);
                                   zendi_convert_scalar_to_number(op2, op2_copy, result);
                                   converted = 1;
                            } else {
                                   zend_error(E_ERROR, "Unsupported operand types");
                                   return FAILURE; /* unknown datatype */
                            }
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API int zend_atoi ( const char *  str,
int  str_len 
)

Definition at line 48 of file zend_operators.c.

{
       int retval;

       if (!str_len) {
              str_len = strlen(str);
       }
       retval = strtol(str, NULL, 0);
       if (str_len>0) {
              switch (str[str_len-1]) {
                     case 'g':
                     case 'G':
                            retval *= 1024;
                            /* break intentionally missing */
                     case 'm':
                     case 'M':
                            retval *= 1024;
                            /* break intentionally missing */
                     case 'k':
                     case 'K':
                            retval *= 1024;
                            break;
              }
       }
       return retval;
}

Here is the caller graph for this function:

ZEND_API long zend_atol ( const char *  str,
int  str_len 
)

Definition at line 76 of file zend_operators.c.

{
       long retval;

       if (!str_len) {
              str_len = strlen(str);
       }
       retval = strtol(str, NULL, 0);
       if (str_len>0) {
              switch (str[str_len-1]) {
                     case 'g':
                     case 'G':
                            retval *= 1024;
                            /* break intentionally missing */
                     case 'm':
                     case 'M':
                            retval *= 1024;
                            /* break intentionally missing */
                     case 'k':
                     case 'K':
                            retval *= 1024;
                            break;
              }
       }
       return retval;
}

Here is the caller graph for this function:

ZEND_API int zend_binary_strcasecmp ( const char *  s1,
uint  len1,
const char *  s2,
uint  len2 
)

Definition at line 1926 of file zend_operators.c.

{
       int len;
       int c1, c2;

       len = MIN(len1, len2);

       while (len--) {
              c1 = zend_tolower((int)*(unsigned char *)s1++);
              c2 = zend_tolower((int)*(unsigned char *)s2++);
              if (c1 != c2) {
                     return c1 - c2;
              }
       }

       return len1 - len2;
}

Here is the caller graph for this function:

ZEND_API int zend_binary_strcmp ( const char *  s1,
uint  len1,
const char *  s2,
uint  len2 
)

Definition at line 1900 of file zend_operators.c.

{
       int retval;

       retval = memcmp(s1, s2, MIN(len1, len2));
       if (!retval) {
              return (len1 - len2);
       } else {
              return retval;
       }
}

Here is the caller graph for this function:

ZEND_API int zend_binary_strncasecmp ( const char *  s1,
uint  len1,
const char *  s2,
uint  len2,
uint  length 
)

Definition at line 1945 of file zend_operators.c.

{
       int len;
       int c1, c2;

       len = MIN(length, MIN(len1, len2));

       while (len--) {
              c1 = zend_tolower((int)*(unsigned char *)s1++);
              c2 = zend_tolower((int)*(unsigned char *)s2++);
              if (c1 != c2) {
                     return c1 - c2;
              }
       }

       return MIN(length, len1) - MIN(length, len2);
}

Here is the caller graph for this function:

ZEND_API int zend_binary_strncmp ( const char *  s1,
uint  len1,
const char *  s2,
uint  len2,
uint  length 
)

Definition at line 1913 of file zend_operators.c.

{
       int retval;

       retval = memcmp(s1, s2, MIN(length, MIN(len1, len2)));
       if (!retval) {
              return (MIN(length, len1) - MIN(length, len2));
       } else {
              return retval;
       }
}

Here is the caller graph for this function:

ZEND_API int zend_binary_zval_strcasecmp ( zval *  s1,
zval *  s2 
)

Definition at line 1976 of file zend_operators.c.

Here is the call graph for this function:

ZEND_API int zend_binary_zval_strcmp ( zval *  s1,
zval *  s2 
)

Definition at line 1964 of file zend_operators.c.

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API int zend_binary_zval_strncasecmp ( zval *  s1,
zval *  s2,
zval *  s3 
)

Definition at line 1982 of file zend_operators.c.

Here is the call graph for this function:

ZEND_API int zend_binary_zval_strncmp ( zval *  s1,
zval *  s2,
zval *  s3 
)

Definition at line 1970 of file zend_operators.c.

Here is the call graph for this function:

ZEND_API void zend_compare_arrays ( zval *  result,
zval *  a1,
zval *a2  TSRMLS_DC 
)

Definition at line 2042 of file zend_operators.c.

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API void zend_compare_objects ( zval *  result,
zval *  o1,
zval *o2  TSRMLS_DC 
)

Definition at line 2048 of file zend_operators.c.

{
       Z_TYPE_P(result) = IS_LONG;

       if (Z_OBJ_HANDLE_P(o1) == Z_OBJ_HANDLE_P(o2)) {
              Z_LVAL_P(result) = 0;
              return;
       }

       if (Z_OBJ_HT_P(o1)->compare_objects == NULL) {
              Z_LVAL_P(result) = 1;
       } else {
              Z_LVAL_P(result) = Z_OBJ_HT_P(o1)->compare_objects(o1, o2 TSRMLS_CC);
       }
}

Here is the caller graph for this function:

ZEND_API void zend_compare_symbol_tables ( zval *  result,
HashTable ht1,
HashTable *ht2  TSRMLS_DC 
)

Definition at line 2036 of file zend_operators.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static zend_always_inline long zend_dval_to_lval ( double  d) [static]

Definition at line 77 of file zend_operators.h.

{
       if (d > LONG_MAX) {
              return (long)(unsigned long) d;
       }
       return (long) d;
}
ZEND_API void zend_locale_sprintf_double ( zval *op  ZEND_FILE_LINE_DC)

Definition at line 2065 of file zend_operators.c.

{
       TSRMLS_FETCH();

       Z_STRLEN_P(op) = zend_spprintf(&Z_STRVAL_P(op), 0, "%.*G", (int) EG(precision), (double)Z_DVAL_P(op));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static char* zend_memnstr ( char *  haystack,
char *  needle,
int  needle_len,
char *  end 
) [inline, static]

Definition at line 227 of file zend_operators.h.

{
       char *p = haystack;
       char ne = needle[needle_len-1];

       if (needle_len == 1) {
              return (char *)memchr(p, *needle, (end-p));
       }

       if (needle_len > end-haystack) {
              return NULL;
       }

       end -= needle_len;

       while (p <= end) {
              if ((p = (char *)memchr(p, *needle, (end-p+1))) && ne == p[needle_len-1]) {
                     if (!memcmp(needle, p, needle_len-1)) {
                            return p;
                     }
              }

              if (p == NULL) {
                     return NULL;
              }

              p++;
       }

       return NULL;
}

Here is the caller graph for this function:

static void* zend_memrchr ( const void *  s,
int  c,
size_t  n 
) [inline, static]

Definition at line 259 of file zend_operators.h.

{
       register unsigned char *e;

       if (n <= 0) {
              return NULL;
       }

       for (e = (unsigned char *)s + n - 1; e >= (unsigned char *)s; e--) {
              if (*e == (unsigned char)c) {
                     return (void *)e;
              }
       }

       return NULL;
}

Here is the caller graph for this function:

ZEND_API void zend_str_tolower ( char *  str,
unsigned int  length 
)

Definition at line 1888 of file zend_operators.c.

{
       register unsigned char *p = (unsigned char*)str;
       register unsigned char *end = p + length;

       while (p < end) {
              *p = zend_tolower((int)*p);
              p++;
       }
}

Here is the caller graph for this function:

ZEND_API char* zend_str_tolower_copy ( char *  dest,
const char *  source,
unsigned int  length 
)

Definition at line 1867 of file zend_operators.c.

{
       register unsigned char *str = (unsigned char*)source;
       register unsigned char *result = (unsigned char*)dest;
       register unsigned char *end = str + length;

       while (str < end) {
              *result++ = zend_tolower((int)*str++);
       }
       *result = '\0';

       return dest;
}
ZEND_API char* zend_str_tolower_dup ( const char *  source,
unsigned int  length 
)

Definition at line 1882 of file zend_operators.c.

{
       return zend_str_tolower_copy((char *)emalloc(length+1), source, length);
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API double zend_string_to_double ( const char *  number,
zend_uint  length 
)

Definition at line 104 of file zend_operators.c.

{
       double divisor = 10.0;
       double result = 0.0;
       double exponent;
       const char *end = number+length;
       const char *digit = number;

       if (!length) {
              return result;
       }

       while (digit < end) {
              if ((*digit <= '9' && *digit >= '0')) {
                     result *= 10;
                     result += *digit - '0';
              } else if (*digit == '.') {
                     digit++;
                     break;
              } else if (toupper(*digit) == 'E') {
                     exponent = (double) atoi(digit+1);
                     result *= pow(10.0, exponent);
                     return result;
              } else {
                     return result;
              }
              digit++;
       }

       while (digit < end) {
              if ((*digit <= '9' && *digit >= '0')) {
                     result += (*digit - '0') / divisor;
                     divisor *= 10;
              } else if (toupper(*digit) == 'E') {
                     exponent = (double) atoi(digit+1);
                     result *= pow(10.0, exponent);
                     return result;
              } else {
                     return result;
              }
              digit++;
       }
       return result;
}
ZEND_API void zendi_smart_strcmp ( zval *  result,
zval *  s1,
zval *  s2 
)

Definition at line 1988 of file zend_operators.c.

{
       int ret1, ret2;
       long lval1, lval2;
       double dval1, dval2;

       if ((ret1=is_numeric_string(Z_STRVAL_P(s1), Z_STRLEN_P(s1), &lval1, &dval1, 0)) &&
              (ret2=is_numeric_string(Z_STRVAL_P(s2), Z_STRLEN_P(s2), &lval2, &dval2, 0))) {
              if ((ret1==IS_DOUBLE) || (ret2==IS_DOUBLE)) {
                     if (ret1!=IS_DOUBLE) {
                            dval1 = (double) lval1;
                     } else if (ret2!=IS_DOUBLE) {
                            dval2 = (double) lval2;
                     } else if (dval1 == dval2 && !zend_finite(dval1)) {
                            /* Both values overflowed and have the same sign,
                             * so a numeric comparison would be inaccurate */
                            goto string_cmp;
                     }
                     Z_DVAL_P(result) = dval1 - dval2;
                     ZVAL_LONG(result, ZEND_NORMALIZE_BOOL(Z_DVAL_P(result)));
              } else { /* they both have to be long's */
                     ZVAL_LONG(result, lval1 > lval2 ? 1 : (lval1 < lval2 ? -1 : 0));
              }
       } else {
string_cmp:
              Z_LVAL_P(result) = zend_binary_zval_strcmp(s1, s2);
              ZVAL_LONG(result, ZEND_NORMALIZE_BOOL(Z_LVAL_P(result)));
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API int zval_is_true ( zval *  op)

Definition at line 1852 of file zend_operators.c.

{
       convert_to_boolean(op);
       return (Z_LVAL_P(op) ? 1 : 0);
}

Here is the call graph for this function:

Here is the caller graph for this function: