Skip to content

Commit

Permalink
Regenerate ext dir
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyklay committed May 18, 2019
1 parent 777038d commit 3665046
Show file tree
Hide file tree
Showing 169 changed files with 15,225 additions and 35,735 deletions.
205 changes: 16 additions & 189 deletions ext/kernel/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,13 @@
#include "php_ext.h"
#include <ext/standard/php_array.h>
#include <Zend/zend_hash.h>
#include <Zend/zend_interfaces.h>

#include "kernel/main.h"
#include "kernel/memory.h"
#include "kernel/debug.h"
#include "kernel/array.h"
#include "kernel/operators.h"
#include "kernel/backtrace.h"
#include "kernel/object.h"
#include "kernel/fcall.h"

void ZEPHIR_FASTCALL zephir_create_array(zval *return_value, uint size, int initialize)
{
Expand Down Expand Up @@ -93,21 +90,7 @@ int zephir_array_isset_fetch(zval *fetched, const zval *arr, zval *index, int re
HashTable *h;
zval *result;

if (UNEXPECTED(Z_TYPE_P(arr) == IS_OBJECT && zephir_instance_of_ev((zval *)arr, (const zend_class_entry *)zend_ce_arrayaccess))) {
zend_long ZEPHIR_LAST_CALL_STATUS;
zval exist;
ZVAL_UNDEF(&exist);
ZEPHIR_CALL_METHOD(&exist, (zval *)arr, "offsetexists", NULL, 0, index);
if (ZEPHIR_LAST_CALL_STATUS != FAILURE && zend_is_true(&exist)) {
ZEPHIR_CALL_METHOD(fetched, (zval *)arr, "offsetget", NULL, 0, index);

return 1;
}

ZVAL_NULL(fetched);

return 0;
} else if (UNEXPECTED(Z_TYPE_P(arr) != IS_ARRAY)) {
if (UNEXPECTED(Z_TYPE_P(arr) != IS_ARRAY)) {
ZVAL_NULL(fetched);

return 0;
Expand Down Expand Up @@ -162,24 +145,8 @@ int zephir_array_isset_fetch(zval *fetched, const zval *arr, zval *index, int re
int zephir_array_isset_string_fetch(zval *fetched, const zval *arr, char *index, uint index_length, int readonly)
{
zval *zv;
if (UNEXPECTED(Z_TYPE_P(arr) == IS_OBJECT && zephir_instance_of_ev((zval *)arr, (const zend_class_entry *)zend_ce_arrayaccess))) {
zend_long ZEPHIR_LAST_CALL_STATUS;
zval exist, offset;
ZVAL_UNDEF(&exist);
ZVAL_STRINGL(&offset, index, index_length);

ZEPHIR_CALL_METHOD(&exist, (zval *)arr, "offsetexists", NULL, 0, &offset);
zval_ptr_dtor(&offset);
if (ZEPHIR_LAST_CALL_STATUS != FAILURE && zend_is_true(&exist)) {
ZEPHIR_CALL_METHOD(fetched, (zval *)arr, "offsetget", NULL, 0, &offset);

return 1;
}

ZVAL_NULL(fetched);

return 0;
} else if (EXPECTED(Z_TYPE_P(arr) == IS_ARRAY)) {
if (EXPECTED(Z_TYPE_P(arr) == IS_ARRAY)) {
if ((zv = zend_hash_str_find(Z_ARRVAL_P(arr), index, index_length)) != NULL) {
zephir_ensure_array(zv);

Expand All @@ -200,23 +167,8 @@ int zephir_array_isset_string_fetch(zval *fetched, const zval *arr, char *index,
int zephir_array_isset_long_fetch(zval *fetched, const zval *arr, unsigned long index, int readonly)
{
zval *zv;

if (UNEXPECTED(Z_TYPE_P(arr) == IS_OBJECT && zephir_instance_of_ev((zval *)arr, (const zend_class_entry *)zend_ce_arrayaccess))) {
zend_long ZEPHIR_LAST_CALL_STATUS;
zval exist, offset;
ZVAL_UNDEF(&exist);
ZVAL_LONG(&offset, index);
ZEPHIR_CALL_METHOD(&exist, (zval *)arr, "offsetexists", NULL, 0, &offset);
if (ZEPHIR_LAST_CALL_STATUS != FAILURE && zend_is_true(&exist)) {
ZEPHIR_CALL_METHOD(fetched, (zval *)arr, "offsetget", NULL, 0, &offset);

return 1;
}

ZVAL_NULL(fetched);

return 0;
} else if (EXPECTED(Z_TYPE_P(arr) == IS_ARRAY)) {
if (EXPECTED(Z_TYPE_P(arr) == IS_ARRAY)) {
if ((zv = zend_hash_index_find(Z_ARRVAL_P(arr), index)) != NULL) {
zephir_ensure_array(zv);

Expand All @@ -238,21 +190,7 @@ int ZEPHIR_FASTCALL zephir_array_isset(const zval *arr, zval *index)
{
HashTable *h;

if (UNEXPECTED(!arr)) {
return 0;
}

if (UNEXPECTED(Z_TYPE_P(arr) == IS_OBJECT && zephir_instance_of_ev((zval *)arr, (const zend_class_entry *)zend_ce_arrayaccess))) {
zend_long ZEPHIR_LAST_CALL_STATUS;
zval exist;
ZVAL_UNDEF(&exist);
ZEPHIR_CALL_METHOD(&exist, (zval *)arr, "offsetexists", NULL, 0, index);
if (zend_is_true(&exist)) {
return 1;
}

return 0;
} else if (UNEXPECTED(Z_TYPE_P(arr) != IS_ARRAY)) {
if (UNEXPECTED(!arr || Z_TYPE_P(arr) != IS_ARRAY)) {
return 0;
}

Expand Down Expand Up @@ -283,19 +221,7 @@ int ZEPHIR_FASTCALL zephir_array_isset(const zval *arr, zval *index)

int ZEPHIR_FASTCALL zephir_array_isset_string(const zval *arr, const char *index, uint index_length)
{
if (UNEXPECTED(Z_TYPE_P(arr) == IS_OBJECT && zephir_instance_of_ev((zval *)arr, (const zend_class_entry *)zend_ce_arrayaccess))) {
zend_long ZEPHIR_LAST_CALL_STATUS;
zval exist, offset;
ZVAL_UNDEF(&exist);
ZVAL_STRINGL(&offset, index, index_length);
ZEPHIR_CALL_METHOD(&exist, (zval *)arr, "offsetexists", NULL, 0, &offset);
zval_ptr_dtor(&offset);
if (ZEPHIR_LAST_CALL_STATUS != FAILURE && zend_is_true(&exist)) {
return 1;
}

return 0;
} else if (EXPECTED(Z_TYPE_P(arr) == IS_ARRAY)) {
if (EXPECTED(Z_TYPE_P(arr) == IS_ARRAY)) {
return zend_hash_str_exists(Z_ARRVAL_P(arr), index, index_length);
}

Expand All @@ -304,18 +230,7 @@ int ZEPHIR_FASTCALL zephir_array_isset_string(const zval *arr, const char *index

int ZEPHIR_FASTCALL zephir_array_isset_long(const zval *arr, unsigned long index)
{
if (UNEXPECTED(Z_TYPE_P(arr) == IS_OBJECT && zephir_instance_of_ev((zval *)arr, (const zend_class_entry *)zend_ce_arrayaccess))) {
zend_long ZEPHIR_LAST_CALL_STATUS;
zval exist, offset;
ZVAL_UNDEF(&exist);
ZVAL_LONG(&offset, index);
ZEPHIR_CALL_METHOD(&exist, (zval *)arr, "offsetexists", NULL, 0, &offset);
if (ZEPHIR_LAST_CALL_STATUS != FAILURE && zend_is_true(&exist)) {
return 1;
}

return 0;
} else if (EXPECTED(Z_TYPE_P(arr) == IS_ARRAY)) {
if (EXPECTED(Z_TYPE_P(arr) == IS_ARRAY)) {
return zend_hash_index_exists(Z_ARRVAL_P(arr), index);
}

Expand All @@ -326,16 +241,8 @@ int ZEPHIR_FASTCALL zephir_array_unset(zval *arr, zval *index, int flags)
{
HashTable *ht;

if (UNEXPECTED(Z_TYPE_P(arr) == IS_OBJECT && zephir_instance_of_ev(arr, (const zend_class_entry *)zend_ce_arrayaccess))) {
zend_long ZEPHIR_LAST_CALL_STATUS;
ZEPHIR_CALL_METHOD(NULL, arr, "offsetunset", NULL, 0, index);
if (ZEPHIR_LAST_CALL_STATUS != FAILURE) {
return 1;
}

return 0;
} else if (Z_TYPE_P(arr) != IS_ARRAY) {
return 0;
if (Z_TYPE_P(arr) != IS_ARRAY) {
return FAILURE;
}

if ((flags & PH_SEPARATE) == PH_SEPARATE) {
Expand Down Expand Up @@ -372,18 +279,7 @@ int ZEPHIR_FASTCALL zephir_array_unset(zval *arr, zval *index, int flags)

int ZEPHIR_FASTCALL zephir_array_unset_string(zval *arr, const char *index, uint index_length, int flags)
{
if (UNEXPECTED(Z_TYPE_P(arr) == IS_OBJECT && zephir_instance_of_ev(arr, (const zend_class_entry *)zend_ce_arrayaccess))) {
zend_long ZEPHIR_LAST_CALL_STATUS;
zval offset;
ZVAL_STRINGL(&offset, index, index_length);
ZEPHIR_CALL_METHOD(NULL, arr, "offsetunset", NULL, 0, &offset);
zval_ptr_dtor(&offset);
if (ZEPHIR_LAST_CALL_STATUS != FAILURE) {
return 1;
}

return 0;
} else if (Z_TYPE_P(arr) != IS_ARRAY) {
if (Z_TYPE_P(arr) != IS_ARRAY) {
return 0;
}

Expand All @@ -396,18 +292,7 @@ int ZEPHIR_FASTCALL zephir_array_unset_string(zval *arr, const char *index, uint

int ZEPHIR_FASTCALL zephir_array_unset_long(zval *arr, unsigned long index, int flags)
{
if (UNEXPECTED(Z_TYPE_P(arr) == IS_OBJECT && zephir_instance_of_ev(arr, (const zend_class_entry *)zend_ce_arrayaccess))) {
zend_long ZEPHIR_LAST_CALL_STATUS;
zval offset;
ZVAL_LONG(&offset, index);
ZEPHIR_CALL_METHOD(NULL, arr, "offsetunset", NULL, 0, &offset);

if (ZEPHIR_LAST_CALL_STATUS != FAILURE) {
return 1;
}

return 0;
} else if (Z_TYPE_P(arr) != IS_ARRAY) {
if (Z_TYPE_P(arr) != IS_ARRAY) {
return 0;
}

Expand Down Expand Up @@ -441,15 +326,7 @@ int zephir_array_fetch(zval *return_value, zval *arr, zval *index, int flags ZEP
ulong uidx = 0;
char *sidx = NULL;

if (UNEXPECTED(Z_TYPE_P(arr) == IS_OBJECT && zephir_instance_of_ev(arr, (const zend_class_entry *)zend_ce_arrayaccess))) {
zend_long ZEPHIR_LAST_CALL_STATUS;
ZEPHIR_CALL_METHOD(return_value, arr, "offsetget", NULL, 0, index);
if (ZEPHIR_LAST_CALL_STATUS != FAILURE) {
return SUCCESS;
}

return FAILURE;
} else if (Z_TYPE_P(arr) == IS_ARRAY) {
if (Z_TYPE_P(arr) == IS_ARRAY) {
ht = Z_ARRVAL_P(arr);
switch (Z_TYPE_P(index)) {
case IS_NULL:
Expand Down Expand Up @@ -517,18 +394,7 @@ int zephir_array_fetch_string(zval *return_value, zval *arr, const char *index,
{
zval *zv;

if (UNEXPECTED(Z_TYPE_P(arr) == IS_OBJECT && zephir_instance_of_ev(arr, (const zend_class_entry *)zend_ce_arrayaccess))) {
zend_long ZEPHIR_LAST_CALL_STATUS;
zval offset;
ZVAL_STRINGL(&offset, index, index_length);
ZEPHIR_CALL_METHOD(return_value, arr, "offsetget", NULL, 0, &offset);
zval_ptr_dtor(&offset);
if (ZEPHIR_LAST_CALL_STATUS != FAILURE) {
return SUCCESS;
}

return FAILURE;
} else if (EXPECTED(Z_TYPE_P(arr) == IS_ARRAY)) {
if (EXPECTED(Z_TYPE_P(arr) == IS_ARRAY)) {
if ((zv = zend_hash_str_find(Z_ARRVAL_P(arr), index, index_length)) != NULL) {

if ((flags & PH_READONLY) == PH_READONLY) {
Expand Down Expand Up @@ -560,17 +426,7 @@ int zephir_array_fetch_long(zval *return_value, zval *arr, unsigned long index,
{
zval *zv;

if (UNEXPECTED(Z_TYPE_P(arr) == IS_OBJECT && zephir_instance_of_ev(arr, (const zend_class_entry *)zend_ce_arrayaccess))) {
zend_long ZEPHIR_LAST_CALL_STATUS;
zval offset;
ZVAL_LONG(&offset, index);
ZEPHIR_CALL_METHOD(return_value, arr, "offsetget", NULL, 0, &offset);
if (ZEPHIR_LAST_CALL_STATUS != FAILURE) {
return SUCCESS;
}

return FAILURE;
} else if (EXPECTED(Z_TYPE_P(arr) == IS_ARRAY)) {
if (EXPECTED(Z_TYPE_P(arr) == IS_ARRAY)) {
if ((zv = zend_hash_index_find(Z_ARRVAL_P(arr), index)) != NULL) {

if ((flags & PH_READONLY) == PH_READONLY) {
Expand Down Expand Up @@ -630,15 +486,7 @@ int zephir_array_update_zval(zval *arr, zval *index, zval *value, int flags)
HashTable *ht;
zval *ret = NULL;

if (UNEXPECTED(Z_TYPE_P(arr) == IS_OBJECT && zephir_instance_of_ev(arr, (const zend_class_entry *)zend_ce_arrayaccess))) {
zend_long ZEPHIR_LAST_CALL_STATUS;
ZEPHIR_CALL_METHOD(NULL, arr, "offsetset", NULL, 0, index, value);
if (ZEPHIR_LAST_CALL_STATUS != FAILURE) {
return SUCCESS;
}

return FAILURE;
} else if (Z_TYPE_P(arr) != IS_ARRAY) {
if (Z_TYPE_P(arr) != IS_ARRAY) {
zend_error(E_WARNING, "Cannot use a scalar value as an array (2)");
return FAILURE;
}
Expand Down Expand Up @@ -694,18 +542,7 @@ int zephir_array_update_zval(zval *arr, zval *index, zval *value, int flags)
int zephir_array_update_string(zval *arr, const char *index, uint index_length, zval *value, int flags)
{

if (UNEXPECTED(Z_TYPE_P(arr) == IS_OBJECT && zephir_instance_of_ev(arr, (const zend_class_entry *)zend_ce_arrayaccess))) {
zend_long ZEPHIR_LAST_CALL_STATUS;
zval offset;
ZVAL_STRINGL(&offset, index, index_length);
ZEPHIR_CALL_METHOD(NULL, arr, "offsetset", NULL, 0, &offset, value);
zval_ptr_dtor(&offset);
if (ZEPHIR_LAST_CALL_STATUS != FAILURE) {
return SUCCESS;
}

return FAILURE;
} else if (Z_TYPE_P(arr) != IS_ARRAY) {
if (Z_TYPE_P(arr) != IS_ARRAY) {
zend_error(E_WARNING, "Cannot use a scalar value as an array (3)");
return FAILURE;
}
Expand All @@ -728,17 +565,7 @@ int zephir_array_update_string(zval *arr, const char *index, uint index_length,

int zephir_array_update_long(zval *arr, unsigned long index, zval *value, int flags ZEPHIR_DEBUG_PARAMS)
{
if (UNEXPECTED(Z_TYPE_P(arr) == IS_OBJECT && zephir_instance_of_ev(arr, (const zend_class_entry *)zend_ce_arrayaccess))) {
zend_long ZEPHIR_LAST_CALL_STATUS;
zval offset;
ZVAL_LONG(&offset, index);
ZEPHIR_CALL_METHOD(NULL, arr, "offsetset", NULL, 0, &offset, value);
if (ZEPHIR_LAST_CALL_STATUS != FAILURE) {
return SUCCESS;
}

return FAILURE;
} else if (Z_TYPE_P(arr) != IS_ARRAY) {
if (Z_TYPE_P(arr) != IS_ARRAY) {
zend_error(E_WARNING, "Cannot use a scalar value as an array in %s on line %d", file, line);
return FAILURE;
}
Expand Down
2 changes: 0 additions & 2 deletions ext/kernel/fcall.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,6 @@ int zephir_call_user_function(zval *object_pp, zend_class_entry *obj_ce, zephir_
}
else if (FAILURE == status || EG(exception)) {
ZVAL_NULL(retval_ptr);
} else if (Z_TYPE_P(retval_ptr) == IS_ARRAY) {
SEPARATE_ARRAY(retval_ptr);
}

return status;
Expand Down
25 changes: 4 additions & 21 deletions ext/kernel/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "kernel/main.h"
#include "kernel/memory.h"
#include "kernel/fcall.h"
#include "kernel/object.h"
#include "kernel/exception.h"


Expand All @@ -33,9 +32,7 @@ zend_string* i_self = NULL;

int zephir_is_iterable_ex(zval *arr, int duplicate)
{
if (UNEXPECTED(Z_TYPE_P(arr) == IS_OBJECT && zephir_instance_of_ev(arr, (const zend_class_entry *)zend_ce_iterator))) {
return 1;
} else if (UNEXPECTED(Z_TYPE_P(arr) != IS_ARRAY)) {
if (UNEXPECTED(Z_TYPE_P(arr) != IS_ARRAY)) {
return 0;
}
//TODO: duplicate
Expand Down Expand Up @@ -85,10 +82,9 @@ int zephir_fetch_parameters(int num_args, int required_args, int optional_args,
/**
* Gets the global zval into PG macro
*/
int zephir_get_global(zval *arr, const char *global, unsigned int global_length)
int zephir_get_global(zval **arr, const char *global, unsigned int global_length)
{
zval *gv;
zend_array *symbol_table;
zend_bool jit_initialization = PG(auto_globals_jit);
zend_string *str = zend_string_init(global, global_length, 0);

Expand All @@ -100,27 +96,14 @@ int zephir_get_global(zval *arr, const char *global, unsigned int global_length)
if ((gv = zend_hash_find_ind(&EG(symbol_table), str)) != NULL) {
ZVAL_DEREF(gv);
if (Z_TYPE_P(gv) == IS_ARRAY) {
if (Z_REFCOUNTED_P(gv)) {
ZVAL_COPY_VALUE(arr, gv);
Z_SET_REFCOUNT_P(arr, 1);
} else {
ZVAL_DUP(arr, gv);
zend_hash_update(&EG(symbol_table), str, arr);
}
*arr = gv;
zend_string_release(str);
return SUCCESS;
}
}
}

array_init(arr);
if (!(&EG(symbol_table))) {
symbol_table = zend_rebuild_symbol_table();
} else {
symbol_table = &EG(symbol_table);
}
zend_hash_update(symbol_table, str, arr);

*arr = NULL;
zend_string_release(str);
return FAILURE;
}
Expand Down
Loading

0 comments on commit 3665046

Please sign in to comment.