From 8d03d8aa9e14af09f0f1be64ac5d2d1b44bb4d30 Mon Sep 17 00:00:00 2001 From: Katie Volz Date: Tue, 1 Feb 2022 14:29:54 -0500 Subject: [PATCH 1/5] Generate includes files directly from PHP --- composer.json | 2 +- include/Dockerfile | 80 ++ include/README | 2 + include/engine_7_4_x64_nts.h | 902 +++++++++++++++++++++ include/engine_7_4_x64_zts.h | 901 +++++++++++++++++++++ include/engine_8_0_x64_nts.h | 914 +++++++++++++++++++++ include/engine_8_0_x64_zts.h | 913 +++++++++++++++++++++ include/engine_8_1_x64_nts.h | 942 ++++++++++++++++++++++ include/engine_8_1_x64_zts.h | 941 ++++++++++++++++++++++ include/engine_x64_nts.h | 1323 ------------------------------- include/process.php | 138 ++++ include/symbols_7_4_x64_nts.txt | 194 +++++ include/symbols_7_4_x64_zts.txt | 193 +++++ include/symbols_8_0_x64_nts.txt | 192 +++++ include/symbols_8_0_x64_zts.txt | 191 +++++ include/symbols_8_1_x64_nts.txt | 196 +++++ include/symbols_8_1_x64_zts.txt | 195 +++++ src/Core.php | 6 +- src/System/Compiler.php | 2 +- 19 files changed, 6900 insertions(+), 1327 deletions(-) create mode 100644 include/Dockerfile create mode 100644 include/README create mode 100644 include/engine_7_4_x64_nts.h create mode 100644 include/engine_7_4_x64_zts.h create mode 100644 include/engine_8_0_x64_nts.h create mode 100644 include/engine_8_0_x64_zts.h create mode 100644 include/engine_8_1_x64_nts.h create mode 100644 include/engine_8_1_x64_zts.h delete mode 100644 include/engine_x64_nts.h create mode 100644 include/process.php create mode 100644 include/symbols_7_4_x64_nts.txt create mode 100644 include/symbols_7_4_x64_zts.txt create mode 100644 include/symbols_8_0_x64_nts.txt create mode 100644 include/symbols_8_0_x64_zts.txt create mode 100644 include/symbols_8_1_x64_nts.txt create mode 100644 include/symbols_8_1_x64_zts.txt diff --git a/composer.json b/composer.json index 6874cb7..9c8f3ba 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Library that provides direct access to native PHP structures", "type": "library", "require": { - "php": "8.0.*", + "php": "7.4.* || 8.0.* || 8.1.*", "ext-ffi": "*" }, "license": [ diff --git a/include/Dockerfile b/include/Dockerfile new file mode 100644 index 0000000..f731dbf --- /dev/null +++ b/include/Dockerfile @@ -0,0 +1,80 @@ +FROM php:8.1.0-bullseye AS php-8_1_x64_nts-build +RUN apt update +RUN apt install libffi-dev +RUN docker-php-ext-install ffi +RUN curl http://131.123.42.38/lmcrs/v1.0.0/srcml_1.0.0-1_ubuntu20.04.deb > srcml.deb +RUN apt install -y ./srcml.deb +COPY process.php . +COPY symbols_8_1_x64_nts.txt . +RUN php process.php +FROM scratch AS php-8_1_x64_nts +COPY --from=php-8_1_x64_nts-build /engine_8_1_x64_nts.h /engine_8_1_x64_nts.h + +FROM php:8.1.0-zts-bullseye AS php-8_1_x64_zts-build +RUN apt update +RUN apt install libffi-dev +RUN docker-php-ext-install ffi +RUN curl http://131.123.42.38/lmcrs/v1.0.0/srcml_1.0.0-1_ubuntu20.04.deb > srcml.deb +RUN apt install -y ./srcml.deb +COPY process.php . +COPY symbols_8_1_x64_zts.txt . +RUN php process.php +FROM scratch AS php-8_1_x64_zts +COPY --from=php-8_1_x64_zts-build /engine_8_1_x64_zts.h / + +FROM php:8.0.0-buster AS php-8_0_x64_nts-build +RUN apt update +RUN apt install libffi-dev +RUN docker-php-ext-install ffi +RUN curl http://131.123.42.38/lmcrs/v1.0.0/srcml_1.0.0-1_ubuntu19.04.deb > srcml.deb +RUN apt install -y ./srcml.deb +COPY process.php . +COPY symbols_8_0_x64_nts.txt . +RUN php process.php +FROM scratch AS php-8_0_x64_nts +COPY --from=php-8_0_x64_nts-build /engine_8_0_x64_nts.h /engine_8_0_x64_nts.h + +FROM php:8.0.0-zts-buster AS php-8_0_x64_zts-build +RUN apt update +RUN apt install libffi-dev +RUN docker-php-ext-install ffi +RUN curl http://131.123.42.38/lmcrs/v1.0.0/srcml_1.0.0-1_ubuntu19.04.deb > srcml.deb +RUN apt install -y ./srcml.deb +COPY process.php . +COPY symbols_8_0_x64_zts.txt . +RUN php process.php +FROM scratch AS php-8_0_x64_zts +COPY --from=php-8_0_x64_zts-build /engine_8_0_x64_zts.h / + +FROM php:7.4.0-buster AS php-7_4_x64_nts-build +RUN apt update +RUN apt install libffi-dev +RUN docker-php-ext-install ffi +RUN curl http://131.123.42.38/lmcrs/v1.0.0/srcml_1.0.0-1_ubuntu19.04.deb > srcml.deb +RUN apt install -y ./srcml.deb +COPY process.php . +COPY symbols_7_4_x64_nts.txt . +RUN php process.php +FROM scratch AS php-7_4_x64_nts +COPY --from=php-7_4_x64_nts-build /engine_7_4_x64_nts.h /engine_7_4_x64_nts.h + +FROM php:7.4.0-zts-buster AS php-7_4_x64_zts-build +RUN apt update +RUN apt install libffi-dev +RUN docker-php-ext-install ffi +RUN curl http://131.123.42.38/lmcrs/v1.0.0/srcml_1.0.0-1_ubuntu19.04.deb > srcml.deb +RUN apt install -y ./srcml.deb +COPY process.php . +COPY symbols_7_4_x64_zts.txt . +RUN php process.php +FROM scratch AS php-7_4_x64_zts +COPY --from=php-7_4_x64_zts-build /engine_7_4_x64_zts.h / + + +FROM scratch +COPY --from=php-8_1_x64_zts /engine_8_1_x64_zts.h / +COPY --from=php-8_1_x64_nts /engine_8_1_x64_nts.h / +COPY --from=php-8_0_x64_zts /engine_8_0_x64_zts.h / +COPY --from=php-8_0_x64_nts /engine_8_0_x64_nts.h / +COPY --from=php-7_4_x64_zts /engine_7_4_x64_zts.h / +COPY --from=php-7_4_x64_nts /engine_7_4_x64_nts.h / diff --git a/include/README b/include/README new file mode 100644 index 0000000..c3f92bd --- /dev/null +++ b/include/README @@ -0,0 +1,2 @@ +To regenerate headers, run: docker buildx build . -o . +To generate headers without checking (useful for getting a copy of the header file to identify any errors), comment out the last line of process.php \ No newline at end of file diff --git a/include/engine_7_4_x64_nts.h b/include/engine_7_4_x64_nts.h new file mode 100644 index 0000000..34babc4 --- /dev/null +++ b/include/engine_7_4_x64_nts.h @@ -0,0 +1,902 @@ +#define FFI_SCOPE "ZEngine" +#define FFI_LIB "ZEND_LIBRARY_NAME" +typedef int64_t zend_long; +typedef uint64_t zend_ulong; +typedef int64_t zend_off_t; +typedef unsigned char zend_bool; +typedef unsigned char zend_uchar; +typedef uintptr_t zend_type; +typedef enum { + SUCCESS = 0, + FAILURE = -1, +} ZEND_RESULT_CODE; +typedef struct _zend_object_handlers zend_object_handlers; +typedef struct _zend_class_entry zend_class_entry; +typedef union _zend_function zend_function; +typedef struct _zend_execute_data zend_execute_data; +typedef struct _zval_struct zval; +typedef struct _zend_refcounted zend_refcounted; +typedef struct _zend_string zend_string; +typedef struct _zend_array zend_array; +typedef struct _zend_object zend_object; +typedef struct _zend_resource zend_resource; +typedef struct _zend_reference zend_reference; +typedef struct _zend_ast_ref zend_ast_ref; +typedef struct _zend_ast zend_ast; +typedef int (*compare_func_t)(const void *, const void *); +typedef void (*swap_func_t)(void *, void *); +typedef void (*sort_func_t)(void *, size_t, size_t, compare_func_t, swap_func_t); +typedef void (*dtor_func_t)(zval *pDest); +typedef void (*copy_ctor_func_t)(zval *pElement); +typedef union _zend_value { + zend_long lval; + double dval; + zend_refcounted *counted; + zend_string *str; + zend_array *arr; + zend_object *obj; + zend_resource *res; + zend_reference *ref; + zend_ast_ref *ast; + zval *zv; + void *ptr; + zend_class_entry *ce; + zend_function *func; + struct { + uint32_t w1; + uint32_t w2; + } ww; +} zend_value; +struct _zval_struct { + zend_value value; + union { + struct { + zend_uchar type; zend_uchar type_flags; union { uint16_t extra; } u; + } v; + uint32_t type_info; + } u1; + union { + uint32_t next; + uint32_t cache_slot; + uint32_t opline_num; + uint32_t lineno; + uint32_t num_args; + uint32_t fe_pos; + uint32_t fe_iter_idx; + uint32_t access_flags; + uint32_t property_guard; + uint32_t constant_flags; + uint32_t extra; + } u2; +}; +typedef struct _zend_refcounted_h { + uint32_t refcount; + union { + uint32_t type_info; + } u; +} zend_refcounted_h; +struct _zend_refcounted { + zend_refcounted_h gc; +}; +struct _zend_string { + zend_refcounted_h gc; + zend_ulong h; + size_t len; + char val[1]; +}; +typedef struct _Bucket { + zval val; + zend_ulong h; + zend_string *key; +} Bucket; +typedef struct _zend_array HashTable; +struct _zend_array { + zend_refcounted_h gc; + union { + struct { + zend_uchar flags; zend_uchar _unused; zend_uchar nIteratorsCount; zend_uchar _unused2; + } v; + uint32_t flags; + } u; + uint32_t nTableMask; + Bucket *arData; + uint32_t nNumUsed; + uint32_t nNumOfElements; + uint32_t nTableSize; + uint32_t nInternalPointer; + zend_long nNextFreeElement; + dtor_func_t pDestructor; +}; +typedef uint32_t HashPosition; +typedef struct _HashTableIterator { + HashTable *ht; + HashPosition pos; +} HashTableIterator; +struct _zend_object { + zend_refcounted_h gc; + uint32_t handle; + zend_class_entry *ce; + const zend_object_handlers *handlers; + HashTable *properties; + zval properties_table[1]; +}; +struct _zend_resource { + zend_refcounted_h gc; + int handle; + int type; + void *ptr; +}; +typedef struct { + size_t num; + size_t num_allocated; + struct _zend_property_info *ptr[1]; +} zend_property_info_list; +typedef union { + struct _zend_property_info *ptr; + uintptr_t list; +} zend_property_info_source_list; +struct _zend_reference { + zend_refcounted_h gc; + zval val; + zend_property_info_source_list sources; +}; +struct _zend_ast_ref { + zend_refcounted_h gc; +}; +typedef uint16_t zend_ast_kind; +typedef uint16_t zend_ast_attr; +struct _zend_ast { + zend_ast_kind kind; + zend_ast_attr attr; + uint32_t lineno; + zend_ast *child[1]; +}; +typedef struct _zend_ast_list { + zend_ast_kind kind; + zend_ast_attr attr; + uint32_t lineno; + uint32_t children; + zend_ast *child[1]; +} zend_ast_list; +typedef struct _zend_ast_zval { + zend_ast_kind kind; + zend_ast_attr attr; + zval val; +} zend_ast_zval; +typedef struct _zend_ast_decl { + zend_ast_kind kind; + zend_ast_attr attr; + uint32_t start_lineno; + uint32_t end_lineno; + uint32_t flags; + unsigned char *lex_pos; + zend_string *doc_comment; + zend_string *name; + zend_ast *child[4]; +} zend_ast_decl; +typedef void (*zend_ast_process_t)(zend_ast *ast); +typedef intptr_t zend_intptr_t; +typedef uintptr_t zend_uintptr_t; +typedef struct _zend_arena zend_arena; +struct _zend_arena { + char *ptr; + char *end; + zend_arena *prev; +}; +typedef struct _zend_op_array zend_op_array; +typedef struct _zend_op zend_op; +typedef union _znode_op { + uint32_t constant; + uint32_t var; + uint32_t num; + uint32_t opline_num; + uint32_t jmp_offset; +} znode_op; +typedef struct _znode { + zend_uchar op_type; + zend_uchar flag; + union { + znode_op op; + zval constant; + } u; +} znode; +typedef struct _zend_ast_znode { + zend_ast_kind kind; + zend_ast_attr attr; + uint32_t lineno; + znode node; +} zend_ast_znode; +typedef struct _zend_declarables { + zend_long ticks; +} zend_declarables; +typedef struct _zend_file_context { + zend_declarables declarables; + zend_string *current_namespace; + zend_bool in_namespace; + zend_bool has_bracketed_namespaces; + HashTable *imports; + HashTable *imports_function; + HashTable *imports_const; + HashTable seen_symbols; +} zend_file_context; +typedef union _zend_parser_stack_elem { + zend_ast *ast; + zend_string *str; + zend_ulong num; + unsigned char *ptr; +} zend_parser_stack_elem; +typedef int (*user_opcode_handler_t) (zend_execute_data *execute_data); +struct _zend_op { + const void *handler; + znode_op op1; + znode_op op2; + znode_op result; + uint32_t extended_value; + uint32_t lineno; + zend_uchar opcode; + zend_uchar op1_type; + zend_uchar op2_type; + zend_uchar result_type; +}; +typedef struct _zend_brk_cont_element { + int start; + int cont; + int brk; + int parent; + zend_bool is_switch; +} zend_brk_cont_element; +typedef struct _zend_label { + int brk_cont; + uint32_t opline_num; +} zend_label; +typedef struct _zend_try_catch_element { + uint32_t try_op; + uint32_t catch_op; + uint32_t finally_op; + uint32_t finally_end; +} zend_try_catch_element; +typedef struct _zend_live_range { + uint32_t var; + uint32_t start; + uint32_t end; +} zend_live_range; +typedef struct _zend_oparray_context { + uint32_t opcodes_size; + int vars_size; + int literals_size; + uint32_t fast_call_var; + uint32_t try_catch_offset; + int current_brk_cont; + int last_brk_cont; + zend_brk_cont_element *brk_cont_array; + HashTable *labels; +} zend_oparray_context; +typedef struct _zend_property_info { + uint32_t offset; + uint32_t flags; + zend_string *name; + zend_string *doc_comment; + zend_class_entry *ce; + zend_type type; +} zend_property_info; +typedef struct _zend_class_constant { + zval value; + zend_string *doc_comment; + zend_class_entry *ce; +} zend_class_constant; +typedef struct _zend_internal_arg_info { + const char *name; + zend_type type; + zend_uchar pass_by_reference; + zend_bool is_variadic; +} zend_internal_arg_info; +typedef struct _zend_arg_info { + zend_string *name; + zend_type type; + zend_uchar pass_by_reference; + zend_bool is_variadic; +} zend_arg_info; +typedef struct _zend_internal_function_info { + zend_uintptr_t required_num_args; + zend_type type; + zend_bool return_reference; + zend_bool _is_variadic; +} zend_internal_function_info; +struct _zend_op_array { + zend_uchar type; + zend_uchar arg_flags[3]; + uint32_t fn_flags; + zend_string *function_name; + zend_class_entry *scope; + zend_function *prototype; + uint32_t num_args; + uint32_t required_num_args; + zend_arg_info *arg_info; + int cache_size; + int last_var; + uint32_t T; + uint32_t last; + zend_op *opcodes; + void ** * run_time_cache__ptr; + HashTable * * static_variables_ptr__ptr; + HashTable *static_variables; + zend_string **vars; + uint32_t *refcount; + int last_live_range; + int last_try_catch; + zend_live_range *live_range; + zend_try_catch_element *try_catch_array; + zend_string *filename; + uint32_t line_start; + uint32_t line_end; + zend_string *doc_comment; + int last_literal; + zval *literals; + void *reserved[6]; +}; +typedef void ( *zif_handler)(zend_execute_data *execute_data, zval *return_value); +typedef struct _zend_internal_function { + zend_uchar type; + zend_uchar arg_flags[3]; + uint32_t fn_flags; + zend_string* function_name; + zend_class_entry *scope; + zend_function *prototype; + uint32_t num_args; + uint32_t required_num_args; + zend_internal_arg_info *arg_info; + zif_handler handler; + struct _zend_module_entry *module; + void *reserved[6]; +} zend_internal_function; +union _zend_function { + zend_uchar type; + uint32_t quick_arg_flags; + struct { + zend_uchar type; + zend_uchar arg_flags[3]; + uint32_t fn_flags; + zend_string *function_name; + zend_class_entry *scope; + zend_function *prototype; + uint32_t num_args; + uint32_t required_num_args; + zend_arg_info *arg_info; + } common; + zend_op_array op_array; + zend_internal_function internal_function; +}; +struct _zend_execute_data { + const zend_op *opline; + zend_execute_data *call; + zval *return_value; + zend_function *func; + zval This; + zend_execute_data *prev_execute_data; + zend_array *symbol_table; + void **run_time_cache; +}; +typedef struct _zend_closure { + zend_object std; + zend_function func; + zval this_ptr; + zend_class_entry *called_scope; + zif_handler orig_internal_handler; +} zend_closure; +extern const zend_object_handlers std_object_handlers; +typedef zval *(*zend_object_read_property_t)(zval *object, zval *member, int type, void **cache_slot, zval *rv); +typedef zval *(*zend_object_read_dimension_t)(zval *object, zval *offset, int type, zval *rv); +typedef zval *(*zend_object_write_property_t)(zval *object, zval *member, zval *value, void **cache_slot); +typedef void (*zend_object_write_dimension_t)(zval *object, zval *offset, zval *value); +typedef zval *(*zend_object_get_property_ptr_ptr_t)(zval *object, zval *member, int type, void **cache_slot); +typedef int (*zend_object_has_property_t)(zval *object, zval *member, int has_set_exists, void **cache_slot); +typedef int (*zend_object_has_dimension_t)(zval *object, zval *member, int check_empty); +typedef void (*zend_object_unset_property_t)(zval *object, zval *member, void **cache_slot); +typedef void (*zend_object_unset_dimension_t)(zval *object, zval *offset); +typedef HashTable *(*zend_object_get_properties_t)(zval *object); +typedef HashTable *(*zend_object_get_debug_info_t)(zval *object, int *is_temp); +typedef enum _zend_prop_purpose { + ZEND_PROP_PURPOSE_DEBUG, + ZEND_PROP_PURPOSE_ARRAY_CAST, + ZEND_PROP_PURPOSE_SERIALIZE, + ZEND_PROP_PURPOSE_VAR_EXPORT, + ZEND_PROP_PURPOSE_JSON, + _ZEND_PROP_PURPOSE_ARRAY_KEY_EXISTS, + _ZEND_PROP_PURPOSE_NON_EXHAUSTIVE_ENUM +} zend_prop_purpose; +typedef zend_array *(*zend_object_get_properties_for_t)(zval *object, zend_prop_purpose purpose); +typedef zend_function *(*zend_object_get_method_t)(zend_object **object, zend_string *method, const zval *key); +typedef zend_function *(*zend_object_get_constructor_t)(zend_object *object); +typedef void (*zend_object_dtor_obj_t)(zend_object *object); +typedef void (*zend_object_free_obj_t)(zend_object *object); +typedef zend_object* (*zend_object_clone_obj_t)(zval *object); +typedef zend_string *(*zend_object_get_class_name_t)(const zend_object *object); +typedef int (*zend_object_compare_t)(zval *object1, zval *object2); +typedef int (*zend_object_cast_t)(zval *readobj, zval *retval, int type); +typedef int (*zend_object_count_elements_t)(zval *object, zend_long *count); +typedef int (*zend_object_get_closure_t)(zval *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr); +typedef HashTable *(*zend_object_get_gc_t)(zval *object, zval **table, int *n); +typedef int (*zend_object_do_operation_t)(zend_uchar opcode, zval *result, zval *op1, zval *op2); +typedef zval* (*zend_object_get_t)(zval *object, zval *rv); +typedef void (*zend_object_set_t)(zval *object, zval *value); +typedef int (*zend_object_call_method_t)(zend_string *method, zend_object *object, zend_execute_data *execute_data, zval *return_value); +typedef int (*zend_object_compare_zvals_t)(zval *result, zval *op1, zval *op2); +struct _zend_object_handlers { + int offset; + zend_object_free_obj_t free_obj; + zend_object_dtor_obj_t dtor_obj; + zend_object_clone_obj_t clone_obj; + zend_object_read_property_t read_property; + zend_object_write_property_t write_property; + zend_object_read_dimension_t read_dimension; + zend_object_write_dimension_t write_dimension; + zend_object_get_property_ptr_ptr_t get_property_ptr_ptr; + zend_object_get_t get; + zend_object_set_t set; + zend_object_has_property_t has_property; + zend_object_unset_property_t unset_property; + zend_object_has_dimension_t has_dimension; + zend_object_unset_dimension_t unset_dimension; + zend_object_get_properties_t get_properties; + zend_object_get_method_t get_method; + zend_object_call_method_t call_method; + zend_object_get_constructor_t get_constructor; + zend_object_get_class_name_t get_class_name; + zend_object_compare_t compare_objects; + zend_object_cast_t cast_object; + zend_object_count_elements_t count_elements; + zend_object_get_debug_info_t get_debug_info; + zend_object_get_closure_t get_closure; + zend_object_get_gc_t get_gc; + zend_object_do_operation_t do_operation; + zend_object_compare_zvals_t compare; + zend_object_get_properties_for_t get_properties_for; +}; +typedef struct _zend_llist_element { + struct _zend_llist_element *next; + struct _zend_llist_element *prev; + char data[1]; +} zend_llist_element; +typedef void (*llist_dtor_func_t)(void *); +typedef int (*llist_compare_func_t)(const zend_llist_element **, const zend_llist_element **); +typedef void (*llist_apply_with_args_func_t)(void *data, int num_args, va_list args); +typedef void (*llist_apply_with_arg_func_t)(void *data, void *arg); +typedef void (*llist_apply_func_t)(void *); +typedef struct _zend_llist { + zend_llist_element *head; + zend_llist_element *tail; + size_t count; + size_t size; + llist_dtor_func_t dtor; + unsigned char persistent; + zend_llist_element *traverse_ptr; +} zend_llist; +typedef zend_llist_element* zend_llist_position; +typedef struct _zend_encoding zend_encoding; +typedef struct _zend_stack { + int size, top, max; + void *elements; +} zend_stack; +typedef struct _zend_vm_stack *zend_vm_stack; +typedef struct _zend_ini_entry zend_ini_entry; +typedef enum { + ON_TOKEN, + ON_FEEDBACK, + ON_STOP +} zend_php_scanner_event; +struct _zend_vm_stack { + zval *top; + zval *end; + zend_vm_stack prev; +}; +typedef struct _zend_function_entry { + const char *fname; + zif_handler handler; + const struct _zend_internal_arg_info *arg_info; + uint32_t num_args; + uint32_t flags; +} zend_function_entry; +typedef struct _zend_fcall_info { + size_t size; + zval function_name; + zval *retval; + zval *params; + zend_object *object; + zend_bool no_separation; + uint32_t param_count; +} zend_fcall_info; +typedef struct _zend_fcall_info_cache { + zend_function *function_handler; + zend_class_entry *calling_scope; + zend_class_entry *called_scope; + zend_object *object; +} zend_fcall_info_cache; +typedef struct _zend_object_iterator zend_object_iterator; +typedef struct _zend_object_iterator_funcs { + void (*dtor)(zend_object_iterator *iter); + int (*valid)(zend_object_iterator *iter); + zval *(*get_current_data)(zend_object_iterator *iter); + void (*get_current_key)(zend_object_iterator *iter, zval *key); + void (*move_forward)(zend_object_iterator *iter); + void (*rewind)(zend_object_iterator *iter); + void (*invalidate_current)(zend_object_iterator *iter); +} zend_object_iterator_funcs; +struct _zend_object_iterator { + zend_object std; + zval data; + const zend_object_iterator_funcs *funcs; + zend_ulong index; +}; +typedef struct _zend_class_iterator_funcs { + zend_function *zf_new_iterator; + zend_function *zf_valid; + zend_function *zf_current; + zend_function *zf_key; + zend_function *zf_next; + zend_function *zf_rewind; +} zend_class_iterator_funcs; +struct _zend_serialize_data; +struct _zend_unserialize_data; +typedef struct _zend_serialize_data zend_serialize_data; +typedef struct _zend_unserialize_data zend_unserialize_data; +typedef struct _zend_class_name { + zend_string *name; + zend_string *lc_name; +} zend_class_name; +typedef struct _zend_trait_method_reference { + zend_string *method_name; + zend_string *class_name; +} zend_trait_method_reference; +typedef struct _zend_trait_precedence { + zend_trait_method_reference trait_method; + uint32_t num_excludes; + zend_string *exclude_class_names[1]; +} zend_trait_precedence; +typedef struct _zend_trait_alias { + zend_trait_method_reference trait_method; + zend_string *alias; + uint32_t modifiers; +} zend_trait_alias; +struct _zend_class_entry { + char type; + zend_string *name; + union { + zend_class_entry *parent; + zend_string *parent_name; + }; + int refcount; + uint32_t ce_flags; + int default_properties_count; + int default_static_members_count; + zval *default_properties_table; + zval *default_static_members_table; + zval * * static_members_table__ptr; + HashTable function_table; + HashTable properties_info; + HashTable constants_table; + struct _zend_property_info **properties_info_table; + zend_function *constructor; + zend_function *destructor; + zend_function *clone; + zend_function *__get; + zend_function *__set; + zend_function *__unset; + zend_function *__isset; + zend_function *__call; + zend_function *__callstatic; + zend_function *__tostring; + zend_function *__debugInfo; + zend_function *serialize_func; + zend_function *unserialize_func; + zend_class_iterator_funcs *iterator_funcs_ptr; + union { + zend_object* (*create_object)(zend_class_entry *class_type); + int (*interface_gets_implemented)(zend_class_entry *iface, zend_class_entry *class_type); + }; + zend_object_iterator *(*get_iterator)(zend_class_entry *ce, zval *object, int by_ref); + zend_function *(*get_static_method)(zend_class_entry *ce, zend_string* method); + int (*serialize)(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data); + int (*unserialize)(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data); + uint32_t num_interfaces; + uint32_t num_traits; + union { + zend_class_entry **interfaces; + zend_class_name *interface_names; + }; + zend_class_name *trait_names; + zend_trait_alias **trait_aliases; + zend_trait_precedence **trait_precedences; + union { + struct { + zend_string *filename; + uint32_t line_start; + uint32_t line_end; + zend_string *doc_comment; + } user; + struct { + const struct _zend_function_entry *builtin_functions; + struct _zend_module_entry *module; + } internal; + } info; +}; +typedef enum { + EH_NORMAL = 0, + EH_THROW +} zend_error_handling_t; +typedef struct { + zend_error_handling_t handling; + zend_class_entry *exception; + zval user_handler; +} zend_error_handling; +typedef struct _zend_objects_store { + zend_object **object_buckets; + uint32_t top; + uint32_t size; + int free_list_head; +} zend_objects_store; +struct _zend_ini_entry { + zend_string *name; + int (*on_modify)(zend_ini_entry *entry, zend_string *new_value, void *mh_arg1, void *mh_arg2, void *mh_arg3, int stage); + void *mh_arg1; + void *mh_arg2; + void *mh_arg3; + zend_string *value; + zend_string *orig_value; + void (*displayer)(zend_ini_entry *ini_entry, int type); + int module_number; + uint8_t modifiable; + uint8_t orig_modifiable; + uint8_t modified; +}; +typedef struct _zend_module_entry zend_module_entry; +typedef struct _zend_module_dep zend_module_dep; +struct _zend_module_entry { + unsigned short size; + unsigned int zend_api; + unsigned char zend_debug; + unsigned char zts; + const struct _zend_ini_entry *ini_entry; + const struct _zend_module_dep *deps; + const char *name; + const struct _zend_function_entry *functions; + int (*module_startup_func)(int type, int module_number); + int (*module_shutdown_func)(int type, int module_number); + int (*request_startup_func)(int type, int module_number); + int (*request_shutdown_func)(int type, int module_number); + void (*info_func)(zend_module_entry *zend_module); + const char *version; + size_t globals_size; + void* globals_ptr; + void (*globals_ctor)(void *global); + void (*globals_dtor)(void *global); + int (*post_deactivate_func)(void); + int module_started; + unsigned char type; + void *handle; + int module_number; + const char *build_id; +}; +struct _zend_module_dep { + const char *name; + const char *rel; + const char *version; + unsigned char type; +}; +typedef struct _zend_gc_status { + uint32_t runs; + uint32_t collected; + uint32_t threshold; + uint32_t num_roots; +} zend_gc_status; +struct _zend_compiler_globals { + zend_stack loop_var_stack; + zend_class_entry *active_class_entry; + zend_string *compiled_filename; + int zend_lineno; + zend_op_array *active_op_array; + HashTable *function_table; + HashTable *class_table; + HashTable filenames_table; + HashTable *auto_globals; + zend_bool parse_error; + zend_bool in_compilation; + zend_bool short_tags; + zend_bool unclean_shutdown; + zend_bool ini_parser_unbuffered_errors; + zend_llist open_files; + struct _zend_ini_parser_param *ini_parser_param; + zend_bool skip_shebang; + zend_bool increment_lineno; + zend_string *doc_comment; + uint32_t extra_fn_flags; + uint32_t compiler_options; + zend_oparray_context context; + zend_file_context file_context; + zend_arena *arena; + HashTable interned_strings; + const zend_encoding **script_encoding_list; + size_t script_encoding_list_size; + zend_bool multibyte; + zend_bool detect_unicode; + zend_bool encoding_declared; + zend_ast *ast; + zend_arena *ast_arena; + zend_stack delayed_oplines_stack; + HashTable *memoized_exprs; + int memoize_mode; + void *map_ptr_base; + size_t map_ptr_size; + size_t map_ptr_last; + HashTable *delayed_variance_obligations; + HashTable *delayed_autoloads; +}; +typedef void jmp_buf; +typedef unsigned int fpu_control_t ; +struct _zend_executor_globals { + zval uninitialized_zval; + zval error_zval; + zend_array *symtable_cache[32]; + zend_array **symtable_cache_limit; + zend_array **symtable_cache_ptr; + zend_array symbol_table; + HashTable included_files; + jmp_buf *bailout; + int error_reporting; + int exit_status; + HashTable *function_table; + HashTable *class_table; + HashTable *zend_constants; + zval *vm_stack_top; + zval *vm_stack_end; + zend_vm_stack vm_stack; + size_t vm_stack_page_size; + struct _zend_execute_data *current_execute_data; + zend_class_entry *fake_scope; + zend_long precision; + int ticks_count; + uint32_t persistent_constants_count; + uint32_t persistent_functions_count; + uint32_t persistent_classes_count; + HashTable *in_autoload; + zend_function *autoload_func; + zend_bool full_tables_cleanup; + zend_bool no_extensions; + zend_bool vm_interrupt; + zend_bool timed_out; + zend_long hard_timeout; + HashTable regular_list; + HashTable persistent_list; + int user_error_handler_error_reporting; + zval user_error_handler; + zval user_exception_handler; + zend_stack user_error_handlers_error_reporting; + zend_stack user_error_handlers; + zend_stack user_exception_handlers; + zend_error_handling_t error_handling; + zend_class_entry *exception_class; + zend_long timeout_seconds; + int lambda_count; + HashTable *ini_directives; + HashTable *modified_ini_directives; + zend_ini_entry *error_reporting_ini_entry; + zend_objects_store objects_store; + zend_object *exception, *prev_exception; + const zend_op *opline_before_exception; + zend_op exception_op[3]; + struct _zend_module_entry *current_module; + zend_bool active; + zend_uchar flags; + zend_long assertions; + uint32_t ht_iterators_count; + uint32_t ht_iterators_used; + HashTableIterator *ht_iterators; + HashTableIterator ht_iterators_slots[16]; + void *saved_fpu_cw_ptr; + fpu_control_t saved_fpu_cw; + zend_function trampoline; + zend_op call_trampoline_op; + zend_bool each_deprecation_thrown; + HashTable weakrefs; + zend_bool exception_ignore_args; + void *reserved[6]; +}; +typedef struct _zend_executor_globals zend_executor_globals; +extern zend_executor_globals executor_globals; +extern struct _zend_compiler_globals compiler_globals; +typedef struct _IO_FILE FILE; +typedef size_t (*zend_stream_fsizer_t)(void* handle); +typedef ssize_t (*zend_stream_reader_t)(void* handle, char *buf, size_t len); +typedef void (*zend_stream_closer_t)(void* handle); +typedef enum { + ZEND_HANDLE_FILENAME, + ZEND_HANDLE_FP, + ZEND_HANDLE_STREAM +} zend_stream_type; +typedef struct _zend_stream { + void *handle; + int isatty; + zend_stream_reader_t reader; + zend_stream_fsizer_t fsizer; + zend_stream_closer_t closer; +} zend_stream; +typedef struct _zend_file_handle { + union { + FILE *fp; + zend_stream stream; + } handle; + const char *filename; + zend_string *opened_path; + zend_stream_type type; + zend_bool free_filename; + char *buf; + size_t len; +} zend_file_handle; +typedef struct _zend_ptr_stack { + int top, max; + void **elements; + void **top_element; + zend_bool persistent; +} zend_ptr_stack; +typedef size_t (*zend_encoding_filter)(unsigned char **str, size_t *str_length, const unsigned char *buf, size_t length); +typedef struct _zend_lex_state { + unsigned int yy_leng; + unsigned char *yy_start; + unsigned char *yy_text; + unsigned char *yy_cursor; + unsigned char *yy_marker; + unsigned char *yy_limit; + int yy_state; + zend_stack state_stack; + zend_ptr_stack heredoc_label_stack; + zend_file_handle *in; + uint32_t lineno; + zend_string *filename; + unsigned char *script_org; + size_t script_org_size; + unsigned char *script_filtered; + size_t script_filtered_size; + zend_encoding_filter input_filter; + zend_encoding_filter output_filter; + const zend_encoding *script_encoding; + void (*on_event)(zend_php_scanner_event event, int token, int line, void *context); + void *on_event_context; + zend_ast *ast; + zend_arena *ast_arena; +} zend_lex_state; +typedef struct _zend_heredoc_label { + char *label; + int length; + int indentation; + zend_bool indentation_uses_spaces; +} zend_heredoc_label; +extern zend_ast_process_t zend_ast_process; +extern HashTable module_registry; +int zend_hash_del(HashTable *ht, zend_string *key); +zval* zend_hash_find(const HashTable *ht, zend_string *key); +zval* zend_hash_add_or_update(HashTable *ht, zend_string *key, zval *pData, uint32_t flag); +int zend_set_user_opcode_handler(zend_uchar opcode, user_opcode_handler_t handler); +user_opcode_handler_t zend_get_user_opcode_handler(zend_uchar opcode); +void zend_do_inheritance_ex(zend_class_entry *ce, zend_class_entry *parent_ce, zend_bool checked); +zend_object* zend_objects_new(zend_class_entry *ce); +void zend_object_std_init(zend_object *object, zend_class_entry *ce); +void object_properties_init(zend_object *object, zend_class_entry *class_type); +void zend_save_lexical_state(zend_lex_state *lex_state); +void zend_restore_lexical_state(zend_lex_state *lex_state); +int zend_prepare_string_for_scanning(zval *str, char *filename); +void zend_lex_tstring(zval *zv); +int zendparse(void); +void zend_ast_destroy(zend_ast *ast); +zend_ast * zend_ast_create_list_0(zend_ast_kind kind); +zend_ast * zend_ast_list_add(zend_ast *list, zend_ast *op); +zend_ast * zend_ast_create_zval_ex(zval *zv, zend_ast_attr attr); +zend_ast * zend_ast_create_0(zend_ast_kind kind); +zend_ast * zend_ast_create_1(zend_ast_kind kind, zend_ast *child); +zend_ast * zend_ast_create_2(zend_ast_kind kind, zend_ast *child1, zend_ast *child2); +zend_ast * zend_ast_create_3(zend_ast_kind kind, zend_ast *child1, zend_ast *child2, zend_ast *child3); +zend_ast * zend_ast_create_4(zend_ast_kind kind, zend_ast *child1, zend_ast *child2, zend_ast *child3, zend_ast *child4); +zend_ast *zend_ast_create_decl( + zend_ast_kind kind, uint32_t flags, uint32_t start_lineno, zend_string *doc_comment, + zend_string *name, zend_ast *child0, zend_ast *child1, zend_ast *child2, zend_ast *child3 +); +zend_module_entry* zend_register_module_ex(zend_module_entry *module); +int zend_startup_module_ex(zend_module_entry *module); diff --git a/include/engine_7_4_x64_zts.h b/include/engine_7_4_x64_zts.h new file mode 100644 index 0000000..1771815 --- /dev/null +++ b/include/engine_7_4_x64_zts.h @@ -0,0 +1,901 @@ +#define FFI_SCOPE "ZEngine" +#define FFI_LIB "ZEND_LIBRARY_NAME" +typedef int64_t zend_long; +typedef uint64_t zend_ulong; +typedef int64_t zend_off_t; +typedef unsigned char zend_bool; +typedef unsigned char zend_uchar; +typedef uintptr_t zend_type; +typedef enum { + SUCCESS = 0, + FAILURE = -1, +} ZEND_RESULT_CODE; +typedef struct _zend_object_handlers zend_object_handlers; +typedef struct _zend_class_entry zend_class_entry; +typedef union _zend_function zend_function; +typedef struct _zend_execute_data zend_execute_data; +typedef struct _zval_struct zval; +typedef struct _zend_refcounted zend_refcounted; +typedef struct _zend_string zend_string; +typedef struct _zend_array zend_array; +typedef struct _zend_object zend_object; +typedef struct _zend_resource zend_resource; +typedef struct _zend_reference zend_reference; +typedef struct _zend_ast_ref zend_ast_ref; +typedef struct _zend_ast zend_ast; +typedef int (*compare_func_t)(const void *, const void *); +typedef void (*swap_func_t)(void *, void *); +typedef void (*sort_func_t)(void *, size_t, size_t, compare_func_t, swap_func_t); +typedef void (*dtor_func_t)(zval *pDest); +typedef void (*copy_ctor_func_t)(zval *pElement); +typedef union _zend_value { + zend_long lval; + double dval; + zend_refcounted *counted; + zend_string *str; + zend_array *arr; + zend_object *obj; + zend_resource *res; + zend_reference *ref; + zend_ast_ref *ast; + zval *zv; + void *ptr; + zend_class_entry *ce; + zend_function *func; + struct { + uint32_t w1; + uint32_t w2; + } ww; +} zend_value; +struct _zval_struct { + zend_value value; + union { + struct { + zend_uchar type; zend_uchar type_flags; union { uint16_t extra; } u; + } v; + uint32_t type_info; + } u1; + union { + uint32_t next; + uint32_t cache_slot; + uint32_t opline_num; + uint32_t lineno; + uint32_t num_args; + uint32_t fe_pos; + uint32_t fe_iter_idx; + uint32_t access_flags; + uint32_t property_guard; + uint32_t constant_flags; + uint32_t extra; + } u2; +}; +typedef struct _zend_refcounted_h { + uint32_t refcount; + union { + uint32_t type_info; + } u; +} zend_refcounted_h; +struct _zend_refcounted { + zend_refcounted_h gc; +}; +struct _zend_string { + zend_refcounted_h gc; + zend_ulong h; + size_t len; + char val[1]; +}; +typedef struct _Bucket { + zval val; + zend_ulong h; + zend_string *key; +} Bucket; +typedef struct _zend_array HashTable; +struct _zend_array { + zend_refcounted_h gc; + union { + struct { + zend_uchar flags; zend_uchar _unused; zend_uchar nIteratorsCount; zend_uchar _unused2; + } v; + uint32_t flags; + } u; + uint32_t nTableMask; + Bucket *arData; + uint32_t nNumUsed; + uint32_t nNumOfElements; + uint32_t nTableSize; + uint32_t nInternalPointer; + zend_long nNextFreeElement; + dtor_func_t pDestructor; +}; +typedef uint32_t HashPosition; +typedef struct _HashTableIterator { + HashTable *ht; + HashPosition pos; +} HashTableIterator; +struct _zend_object { + zend_refcounted_h gc; + uint32_t handle; + zend_class_entry *ce; + const zend_object_handlers *handlers; + HashTable *properties; + zval properties_table[1]; +}; +struct _zend_resource { + zend_refcounted_h gc; + int handle; + int type; + void *ptr; +}; +typedef struct { + size_t num; + size_t num_allocated; + struct _zend_property_info *ptr[1]; +} zend_property_info_list; +typedef union { + struct _zend_property_info *ptr; + uintptr_t list; +} zend_property_info_source_list; +struct _zend_reference { + zend_refcounted_h gc; + zval val; + zend_property_info_source_list sources; +}; +struct _zend_ast_ref { + zend_refcounted_h gc; +}; +typedef uint16_t zend_ast_kind; +typedef uint16_t zend_ast_attr; +struct _zend_ast { + zend_ast_kind kind; + zend_ast_attr attr; + uint32_t lineno; + zend_ast *child[1]; +}; +typedef struct _zend_ast_list { + zend_ast_kind kind; + zend_ast_attr attr; + uint32_t lineno; + uint32_t children; + zend_ast *child[1]; +} zend_ast_list; +typedef struct _zend_ast_zval { + zend_ast_kind kind; + zend_ast_attr attr; + zval val; +} zend_ast_zval; +typedef struct _zend_ast_decl { + zend_ast_kind kind; + zend_ast_attr attr; + uint32_t start_lineno; + uint32_t end_lineno; + uint32_t flags; + unsigned char *lex_pos; + zend_string *doc_comment; + zend_string *name; + zend_ast *child[4]; +} zend_ast_decl; +typedef void (*zend_ast_process_t)(zend_ast *ast); +typedef intptr_t zend_intptr_t; +typedef uintptr_t zend_uintptr_t; +typedef struct _zend_arena zend_arena; +struct _zend_arena { + char *ptr; + char *end; + zend_arena *prev; +}; +typedef struct _zend_op_array zend_op_array; +typedef struct _zend_op zend_op; +typedef union _znode_op { + uint32_t constant; + uint32_t var; + uint32_t num; + uint32_t opline_num; + uint32_t jmp_offset; +} znode_op; +typedef struct _znode { + zend_uchar op_type; + zend_uchar flag; + union { + znode_op op; + zval constant; + } u; +} znode; +typedef struct _zend_ast_znode { + zend_ast_kind kind; + zend_ast_attr attr; + uint32_t lineno; + znode node; +} zend_ast_znode; +typedef struct _zend_declarables { + zend_long ticks; +} zend_declarables; +typedef struct _zend_file_context { + zend_declarables declarables; + zend_string *current_namespace; + zend_bool in_namespace; + zend_bool has_bracketed_namespaces; + HashTable *imports; + HashTable *imports_function; + HashTable *imports_const; + HashTable seen_symbols; +} zend_file_context; +typedef union _zend_parser_stack_elem { + zend_ast *ast; + zend_string *str; + zend_ulong num; + unsigned char *ptr; +} zend_parser_stack_elem; +typedef int (*user_opcode_handler_t) (zend_execute_data *execute_data); +struct _zend_op { + const void *handler; + znode_op op1; + znode_op op2; + znode_op result; + uint32_t extended_value; + uint32_t lineno; + zend_uchar opcode; + zend_uchar op1_type; + zend_uchar op2_type; + zend_uchar result_type; +}; +typedef struct _zend_brk_cont_element { + int start; + int cont; + int brk; + int parent; + zend_bool is_switch; +} zend_brk_cont_element; +typedef struct _zend_label { + int brk_cont; + uint32_t opline_num; +} zend_label; +typedef struct _zend_try_catch_element { + uint32_t try_op; + uint32_t catch_op; + uint32_t finally_op; + uint32_t finally_end; +} zend_try_catch_element; +typedef struct _zend_live_range { + uint32_t var; + uint32_t start; + uint32_t end; +} zend_live_range; +typedef struct _zend_oparray_context { + uint32_t opcodes_size; + int vars_size; + int literals_size; + uint32_t fast_call_var; + uint32_t try_catch_offset; + int current_brk_cont; + int last_brk_cont; + zend_brk_cont_element *brk_cont_array; + HashTable *labels; +} zend_oparray_context; +typedef struct _zend_property_info { + uint32_t offset; + uint32_t flags; + zend_string *name; + zend_string *doc_comment; + zend_class_entry *ce; + zend_type type; +} zend_property_info; +typedef struct _zend_class_constant { + zval value; + zend_string *doc_comment; + zend_class_entry *ce; +} zend_class_constant; +typedef struct _zend_internal_arg_info { + const char *name; + zend_type type; + zend_uchar pass_by_reference; + zend_bool is_variadic; +} zend_internal_arg_info; +typedef struct _zend_arg_info { + zend_string *name; + zend_type type; + zend_uchar pass_by_reference; + zend_bool is_variadic; +} zend_arg_info; +typedef struct _zend_internal_function_info { + zend_uintptr_t required_num_args; + zend_type type; + zend_bool return_reference; + zend_bool _is_variadic; +} zend_internal_function_info; +struct _zend_op_array { + zend_uchar type; + zend_uchar arg_flags[3]; + uint32_t fn_flags; + zend_string *function_name; + zend_class_entry *scope; + zend_function *prototype; + uint32_t num_args; + uint32_t required_num_args; + zend_arg_info *arg_info; + int cache_size; + int last_var; + uint32_t T; + uint32_t last; + zend_op *opcodes; + void ** * run_time_cache__ptr; + HashTable * * static_variables_ptr__ptr; + HashTable *static_variables; + zend_string **vars; + uint32_t *refcount; + int last_live_range; + int last_try_catch; + zend_live_range *live_range; + zend_try_catch_element *try_catch_array; + zend_string *filename; + uint32_t line_start; + uint32_t line_end; + zend_string *doc_comment; + int last_literal; + zval *literals; + void *reserved[6]; +}; +typedef void ( *zif_handler)(zend_execute_data *execute_data, zval *return_value); +typedef struct _zend_internal_function { + zend_uchar type; + zend_uchar arg_flags[3]; + uint32_t fn_flags; + zend_string* function_name; + zend_class_entry *scope; + zend_function *prototype; + uint32_t num_args; + uint32_t required_num_args; + zend_internal_arg_info *arg_info; + zif_handler handler; + struct _zend_module_entry *module; + void *reserved[6]; +} zend_internal_function; +union _zend_function { + zend_uchar type; + uint32_t quick_arg_flags; + struct { + zend_uchar type; + zend_uchar arg_flags[3]; + uint32_t fn_flags; + zend_string *function_name; + zend_class_entry *scope; + zend_function *prototype; + uint32_t num_args; + uint32_t required_num_args; + zend_arg_info *arg_info; + } common; + zend_op_array op_array; + zend_internal_function internal_function; +}; +struct _zend_execute_data { + const zend_op *opline; + zend_execute_data *call; + zval *return_value; + zend_function *func; + zval This; + zend_execute_data *prev_execute_data; + zend_array *symbol_table; + void **run_time_cache; +}; +typedef struct _zend_closure { + zend_object std; + zend_function func; + zval this_ptr; + zend_class_entry *called_scope; + zif_handler orig_internal_handler; +} zend_closure; +extern const zend_object_handlers std_object_handlers; +typedef zval *(*zend_object_read_property_t)(zval *object, zval *member, int type, void **cache_slot, zval *rv); +typedef zval *(*zend_object_read_dimension_t)(zval *object, zval *offset, int type, zval *rv); +typedef zval *(*zend_object_write_property_t)(zval *object, zval *member, zval *value, void **cache_slot); +typedef void (*zend_object_write_dimension_t)(zval *object, zval *offset, zval *value); +typedef zval *(*zend_object_get_property_ptr_ptr_t)(zval *object, zval *member, int type, void **cache_slot); +typedef int (*zend_object_has_property_t)(zval *object, zval *member, int has_set_exists, void **cache_slot); +typedef int (*zend_object_has_dimension_t)(zval *object, zval *member, int check_empty); +typedef void (*zend_object_unset_property_t)(zval *object, zval *member, void **cache_slot); +typedef void (*zend_object_unset_dimension_t)(zval *object, zval *offset); +typedef HashTable *(*zend_object_get_properties_t)(zval *object); +typedef HashTable *(*zend_object_get_debug_info_t)(zval *object, int *is_temp); +typedef enum _zend_prop_purpose { + ZEND_PROP_PURPOSE_DEBUG, + ZEND_PROP_PURPOSE_ARRAY_CAST, + ZEND_PROP_PURPOSE_SERIALIZE, + ZEND_PROP_PURPOSE_VAR_EXPORT, + ZEND_PROP_PURPOSE_JSON, + _ZEND_PROP_PURPOSE_ARRAY_KEY_EXISTS, + _ZEND_PROP_PURPOSE_NON_EXHAUSTIVE_ENUM +} zend_prop_purpose; +typedef zend_array *(*zend_object_get_properties_for_t)(zval *object, zend_prop_purpose purpose); +typedef zend_function *(*zend_object_get_method_t)(zend_object **object, zend_string *method, const zval *key); +typedef zend_function *(*zend_object_get_constructor_t)(zend_object *object); +typedef void (*zend_object_dtor_obj_t)(zend_object *object); +typedef void (*zend_object_free_obj_t)(zend_object *object); +typedef zend_object* (*zend_object_clone_obj_t)(zval *object); +typedef zend_string *(*zend_object_get_class_name_t)(const zend_object *object); +typedef int (*zend_object_compare_t)(zval *object1, zval *object2); +typedef int (*zend_object_cast_t)(zval *readobj, zval *retval, int type); +typedef int (*zend_object_count_elements_t)(zval *object, zend_long *count); +typedef int (*zend_object_get_closure_t)(zval *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr); +typedef HashTable *(*zend_object_get_gc_t)(zval *object, zval **table, int *n); +typedef int (*zend_object_do_operation_t)(zend_uchar opcode, zval *result, zval *op1, zval *op2); +typedef zval* (*zend_object_get_t)(zval *object, zval *rv); +typedef void (*zend_object_set_t)(zval *object, zval *value); +typedef int (*zend_object_call_method_t)(zend_string *method, zend_object *object, zend_execute_data *execute_data, zval *return_value); +typedef int (*zend_object_compare_zvals_t)(zval *result, zval *op1, zval *op2); +struct _zend_object_handlers { + int offset; + zend_object_free_obj_t free_obj; + zend_object_dtor_obj_t dtor_obj; + zend_object_clone_obj_t clone_obj; + zend_object_read_property_t read_property; + zend_object_write_property_t write_property; + zend_object_read_dimension_t read_dimension; + zend_object_write_dimension_t write_dimension; + zend_object_get_property_ptr_ptr_t get_property_ptr_ptr; + zend_object_get_t get; + zend_object_set_t set; + zend_object_has_property_t has_property; + zend_object_unset_property_t unset_property; + zend_object_has_dimension_t has_dimension; + zend_object_unset_dimension_t unset_dimension; + zend_object_get_properties_t get_properties; + zend_object_get_method_t get_method; + zend_object_call_method_t call_method; + zend_object_get_constructor_t get_constructor; + zend_object_get_class_name_t get_class_name; + zend_object_compare_t compare_objects; + zend_object_cast_t cast_object; + zend_object_count_elements_t count_elements; + zend_object_get_debug_info_t get_debug_info; + zend_object_get_closure_t get_closure; + zend_object_get_gc_t get_gc; + zend_object_do_operation_t do_operation; + zend_object_compare_zvals_t compare; + zend_object_get_properties_for_t get_properties_for; +}; +typedef struct _zend_llist_element { + struct _zend_llist_element *next; + struct _zend_llist_element *prev; + char data[1]; +} zend_llist_element; +typedef void (*llist_dtor_func_t)(void *); +typedef int (*llist_compare_func_t)(const zend_llist_element **, const zend_llist_element **); +typedef void (*llist_apply_with_args_func_t)(void *data, int num_args, va_list args); +typedef void (*llist_apply_with_arg_func_t)(void *data, void *arg); +typedef void (*llist_apply_func_t)(void *); +typedef struct _zend_llist { + zend_llist_element *head; + zend_llist_element *tail; + size_t count; + size_t size; + llist_dtor_func_t dtor; + unsigned char persistent; + zend_llist_element *traverse_ptr; +} zend_llist; +typedef zend_llist_element* zend_llist_position; +typedef struct _zend_encoding zend_encoding; +typedef struct _zend_stack { + int size, top, max; + void *elements; +} zend_stack; +typedef struct _zend_vm_stack *zend_vm_stack; +typedef struct _zend_ini_entry zend_ini_entry; +typedef enum { + ON_TOKEN, + ON_FEEDBACK, + ON_STOP +} zend_php_scanner_event; +struct _zend_vm_stack { + zval *top; + zval *end; + zend_vm_stack prev; +}; +typedef struct _zend_function_entry { + const char *fname; + zif_handler handler; + const struct _zend_internal_arg_info *arg_info; + uint32_t num_args; + uint32_t flags; +} zend_function_entry; +typedef struct _zend_fcall_info { + size_t size; + zval function_name; + zval *retval; + zval *params; + zend_object *object; + zend_bool no_separation; + uint32_t param_count; +} zend_fcall_info; +typedef struct _zend_fcall_info_cache { + zend_function *function_handler; + zend_class_entry *calling_scope; + zend_class_entry *called_scope; + zend_object *object; +} zend_fcall_info_cache; +typedef struct _zend_object_iterator zend_object_iterator; +typedef struct _zend_object_iterator_funcs { + void (*dtor)(zend_object_iterator *iter); + int (*valid)(zend_object_iterator *iter); + zval *(*get_current_data)(zend_object_iterator *iter); + void (*get_current_key)(zend_object_iterator *iter, zval *key); + void (*move_forward)(zend_object_iterator *iter); + void (*rewind)(zend_object_iterator *iter); + void (*invalidate_current)(zend_object_iterator *iter); +} zend_object_iterator_funcs; +struct _zend_object_iterator { + zend_object std; + zval data; + const zend_object_iterator_funcs *funcs; + zend_ulong index; +}; +typedef struct _zend_class_iterator_funcs { + zend_function *zf_new_iterator; + zend_function *zf_valid; + zend_function *zf_current; + zend_function *zf_key; + zend_function *zf_next; + zend_function *zf_rewind; +} zend_class_iterator_funcs; +struct _zend_serialize_data; +struct _zend_unserialize_data; +typedef struct _zend_serialize_data zend_serialize_data; +typedef struct _zend_unserialize_data zend_unserialize_data; +typedef struct _zend_class_name { + zend_string *name; + zend_string *lc_name; +} zend_class_name; +typedef struct _zend_trait_method_reference { + zend_string *method_name; + zend_string *class_name; +} zend_trait_method_reference; +typedef struct _zend_trait_precedence { + zend_trait_method_reference trait_method; + uint32_t num_excludes; + zend_string *exclude_class_names[1]; +} zend_trait_precedence; +typedef struct _zend_trait_alias { + zend_trait_method_reference trait_method; + zend_string *alias; + uint32_t modifiers; +} zend_trait_alias; +struct _zend_class_entry { + char type; + zend_string *name; + union { + zend_class_entry *parent; + zend_string *parent_name; + }; + int refcount; + uint32_t ce_flags; + int default_properties_count; + int default_static_members_count; + zval *default_properties_table; + zval *default_static_members_table; + zval * * static_members_table__ptr; + HashTable function_table; + HashTable properties_info; + HashTable constants_table; + struct _zend_property_info **properties_info_table; + zend_function *constructor; + zend_function *destructor; + zend_function *clone; + zend_function *__get; + zend_function *__set; + zend_function *__unset; + zend_function *__isset; + zend_function *__call; + zend_function *__callstatic; + zend_function *__tostring; + zend_function *__debugInfo; + zend_function *serialize_func; + zend_function *unserialize_func; + zend_class_iterator_funcs *iterator_funcs_ptr; + union { + zend_object* (*create_object)(zend_class_entry *class_type); + int (*interface_gets_implemented)(zend_class_entry *iface, zend_class_entry *class_type); + }; + zend_object_iterator *(*get_iterator)(zend_class_entry *ce, zval *object, int by_ref); + zend_function *(*get_static_method)(zend_class_entry *ce, zend_string* method); + int (*serialize)(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data); + int (*unserialize)(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data); + uint32_t num_interfaces; + uint32_t num_traits; + union { + zend_class_entry **interfaces; + zend_class_name *interface_names; + }; + zend_class_name *trait_names; + zend_trait_alias **trait_aliases; + zend_trait_precedence **trait_precedences; + union { + struct { + zend_string *filename; + uint32_t line_start; + uint32_t line_end; + zend_string *doc_comment; + } user; + struct { + const struct _zend_function_entry *builtin_functions; + struct _zend_module_entry *module; + } internal; + } info; +}; +typedef enum { + EH_NORMAL = 0, + EH_THROW +} zend_error_handling_t; +typedef struct { + zend_error_handling_t handling; + zend_class_entry *exception; + zval user_handler; +} zend_error_handling; +typedef struct _zend_objects_store { + zend_object **object_buckets; + uint32_t top; + uint32_t size; + int free_list_head; +} zend_objects_store; +struct _zend_ini_entry { + zend_string *name; + int (*on_modify)(zend_ini_entry *entry, zend_string *new_value, void *mh_arg1, void *mh_arg2, void *mh_arg3, int stage); + void *mh_arg1; + void *mh_arg2; + void *mh_arg3; + zend_string *value; + zend_string *orig_value; + void (*displayer)(zend_ini_entry *ini_entry, int type); + int module_number; + uint8_t modifiable; + uint8_t orig_modifiable; + uint8_t modified; +}; +typedef struct _zend_module_entry zend_module_entry; +typedef struct _zend_module_dep zend_module_dep; +typedef int ts_rsrc_id; +struct _zend_module_entry { + unsigned short size; + unsigned int zend_api; + unsigned char zend_debug; + unsigned char zts; + const struct _zend_ini_entry *ini_entry; + const struct _zend_module_dep *deps; + const char *name; + const struct _zend_function_entry *functions; + int (*module_startup_func)(int type, int module_number); + int (*module_shutdown_func)(int type, int module_number); + int (*request_startup_func)(int type, int module_number); + int (*request_shutdown_func)(int type, int module_number); + void (*info_func)(zend_module_entry *zend_module); + const char *version; + size_t globals_size; + ts_rsrc_id* globals_id_ptr; + void (*globals_ctor)(void *global); + void (*globals_dtor)(void *global); + int (*post_deactivate_func)(void); + int module_started; + unsigned char type; + void *handle; + int module_number; + const char *build_id; +}; +struct _zend_module_dep { + const char *name; + const char *rel; + const char *version; + unsigned char type; +}; +typedef struct _zend_gc_status { + uint32_t runs; + uint32_t collected; + uint32_t threshold; + uint32_t num_roots; +} zend_gc_status; +struct _zend_compiler_globals { + zend_stack loop_var_stack; + zend_class_entry *active_class_entry; + zend_string *compiled_filename; + int zend_lineno; + zend_op_array *active_op_array; + HashTable *function_table; + HashTable *class_table; + HashTable filenames_table; + HashTable *auto_globals; + zend_bool parse_error; + zend_bool in_compilation; + zend_bool short_tags; + zend_bool unclean_shutdown; + zend_bool ini_parser_unbuffered_errors; + zend_llist open_files; + struct _zend_ini_parser_param *ini_parser_param; + zend_bool skip_shebang; + zend_bool increment_lineno; + zend_string *doc_comment; + uint32_t extra_fn_flags; + uint32_t compiler_options; + zend_oparray_context context; + zend_file_context file_context; + zend_arena *arena; + HashTable interned_strings; + const zend_encoding **script_encoding_list; + size_t script_encoding_list_size; + zend_bool multibyte; + zend_bool detect_unicode; + zend_bool encoding_declared; + zend_ast *ast; + zend_arena *ast_arena; + zend_stack delayed_oplines_stack; + HashTable *memoized_exprs; + int memoize_mode; + void *map_ptr_base; + size_t map_ptr_size; + size_t map_ptr_last; + HashTable *delayed_variance_obligations; + HashTable *delayed_autoloads; +}; +typedef void jmp_buf; +typedef unsigned int fpu_control_t ; +struct _zend_executor_globals { + zval uninitialized_zval; + zval error_zval; + zend_array *symtable_cache[32]; + zend_array **symtable_cache_limit; + zend_array **symtable_cache_ptr; + zend_array symbol_table; + HashTable included_files; + jmp_buf *bailout; + int error_reporting; + int exit_status; + HashTable *function_table; + HashTable *class_table; + HashTable *zend_constants; + zval *vm_stack_top; + zval *vm_stack_end; + zend_vm_stack vm_stack; + size_t vm_stack_page_size; + struct _zend_execute_data *current_execute_data; + zend_class_entry *fake_scope; + zend_long precision; + int ticks_count; + uint32_t persistent_constants_count; + uint32_t persistent_functions_count; + uint32_t persistent_classes_count; + HashTable *in_autoload; + zend_function *autoload_func; + zend_bool full_tables_cleanup; + zend_bool no_extensions; + zend_bool vm_interrupt; + zend_bool timed_out; + zend_long hard_timeout; + HashTable regular_list; + HashTable persistent_list; + int user_error_handler_error_reporting; + zval user_error_handler; + zval user_exception_handler; + zend_stack user_error_handlers_error_reporting; + zend_stack user_error_handlers; + zend_stack user_exception_handlers; + zend_error_handling_t error_handling; + zend_class_entry *exception_class; + zend_long timeout_seconds; + int lambda_count; + HashTable *ini_directives; + HashTable *modified_ini_directives; + zend_ini_entry *error_reporting_ini_entry; + zend_objects_store objects_store; + zend_object *exception, *prev_exception; + const zend_op *opline_before_exception; + zend_op exception_op[3]; + struct _zend_module_entry *current_module; + zend_bool active; + zend_uchar flags; + zend_long assertions; + uint32_t ht_iterators_count; + uint32_t ht_iterators_used; + HashTableIterator *ht_iterators; + HashTableIterator ht_iterators_slots[16]; + void *saved_fpu_cw_ptr; + fpu_control_t saved_fpu_cw; + zend_function trampoline; + zend_op call_trampoline_op; + zend_bool each_deprecation_thrown; + HashTable weakrefs; + zend_bool exception_ignore_args; + void *reserved[6]; +}; +typedef struct _zend_executor_globals zend_executor_globals; +typedef struct _IO_FILE FILE; +typedef size_t (*zend_stream_fsizer_t)(void* handle); +typedef ssize_t (*zend_stream_reader_t)(void* handle, char *buf, size_t len); +typedef void (*zend_stream_closer_t)(void* handle); +typedef enum { + ZEND_HANDLE_FILENAME, + ZEND_HANDLE_FP, + ZEND_HANDLE_STREAM +} zend_stream_type; +typedef struct _zend_stream { + void *handle; + int isatty; + zend_stream_reader_t reader; + zend_stream_fsizer_t fsizer; + zend_stream_closer_t closer; +} zend_stream; +typedef struct _zend_file_handle { + union { + FILE *fp; + zend_stream stream; + } handle; + const char *filename; + zend_string *opened_path; + zend_stream_type type; + zend_bool free_filename; + char *buf; + size_t len; +} zend_file_handle; +typedef struct _zend_ptr_stack { + int top, max; + void **elements; + void **top_element; + zend_bool persistent; +} zend_ptr_stack; +typedef size_t (*zend_encoding_filter)(unsigned char **str, size_t *str_length, const unsigned char *buf, size_t length); +typedef struct _zend_lex_state { + unsigned int yy_leng; + unsigned char *yy_start; + unsigned char *yy_text; + unsigned char *yy_cursor; + unsigned char *yy_marker; + unsigned char *yy_limit; + int yy_state; + zend_stack state_stack; + zend_ptr_stack heredoc_label_stack; + zend_file_handle *in; + uint32_t lineno; + zend_string *filename; + unsigned char *script_org; + size_t script_org_size; + unsigned char *script_filtered; + size_t script_filtered_size; + zend_encoding_filter input_filter; + zend_encoding_filter output_filter; + const zend_encoding *script_encoding; + void (*on_event)(zend_php_scanner_event event, int token, int line, void *context); + void *on_event_context; + zend_ast *ast; + zend_arena *ast_arena; +} zend_lex_state; +typedef struct _zend_heredoc_label { + char *label; + int length; + int indentation; + zend_bool indentation_uses_spaces; +} zend_heredoc_label; +extern zend_ast_process_t zend_ast_process; +extern HashTable module_registry; +int zend_hash_del(HashTable *ht, zend_string *key); +zval* zend_hash_find(const HashTable *ht, zend_string *key); +zval* zend_hash_add_or_update(HashTable *ht, zend_string *key, zval *pData, uint32_t flag); +int zend_set_user_opcode_handler(zend_uchar opcode, user_opcode_handler_t handler); +user_opcode_handler_t zend_get_user_opcode_handler(zend_uchar opcode); +void zend_do_inheritance_ex(zend_class_entry *ce, zend_class_entry *parent_ce, zend_bool checked); +zend_object* zend_objects_new(zend_class_entry *ce); +void zend_object_std_init(zend_object *object, zend_class_entry *ce); +void object_properties_init(zend_object *object, zend_class_entry *class_type); +void zend_save_lexical_state(zend_lex_state *lex_state); +void zend_restore_lexical_state(zend_lex_state *lex_state); +int zend_prepare_string_for_scanning(zval *str, char *filename); +void zend_lex_tstring(zval *zv); +int zendparse(void); +void zend_ast_destroy(zend_ast *ast); +zend_ast * zend_ast_create_list_0(zend_ast_kind kind); +zend_ast * zend_ast_list_add(zend_ast *list, zend_ast *op); +zend_ast * zend_ast_create_zval_ex(zval *zv, zend_ast_attr attr); +zend_ast * zend_ast_create_0(zend_ast_kind kind); +zend_ast * zend_ast_create_1(zend_ast_kind kind, zend_ast *child); +zend_ast * zend_ast_create_2(zend_ast_kind kind, zend_ast *child1, zend_ast *child2); +zend_ast * zend_ast_create_3(zend_ast_kind kind, zend_ast *child1, zend_ast *child2, zend_ast *child3); +zend_ast * zend_ast_create_4(zend_ast_kind kind, zend_ast *child1, zend_ast *child2, zend_ast *child3, zend_ast *child4); +zend_ast *zend_ast_create_decl( + zend_ast_kind kind, uint32_t flags, uint32_t start_lineno, zend_string *doc_comment, + zend_string *name, zend_ast *child0, zend_ast *child1, zend_ast *child2, zend_ast *child3 +); +zend_module_entry* zend_register_module_ex(zend_module_entry *module); +int zend_startup_module_ex(zend_module_entry *module); diff --git a/include/engine_8_0_x64_nts.h b/include/engine_8_0_x64_nts.h new file mode 100644 index 0000000..075c5c5 --- /dev/null +++ b/include/engine_8_0_x64_nts.h @@ -0,0 +1,914 @@ +#define FFI_SCOPE "ZEngine" +#define FFI_LIB "ZEND_LIBRARY_NAME" +typedef int64_t zend_long; +typedef uint64_t zend_ulong; +typedef int64_t zend_off_t; +typedef _Bool zend_bool; +typedef unsigned char zend_uchar; +typedef struct { + void *ptr; + uint32_t type_mask; +} zend_type; +typedef enum { + SUCCESS = 0, + FAILURE = -1, +} ZEND_RESULT_CODE; +typedef struct _zend_object_handlers zend_object_handlers; +typedef struct _zend_class_entry zend_class_entry; +typedef union _zend_function zend_function; +typedef struct _zend_execute_data zend_execute_data; +typedef struct _zval_struct zval; +typedef struct _zend_refcounted zend_refcounted; +typedef struct _zend_string zend_string; +typedef struct _zend_array zend_array; +typedef struct _zend_object zend_object; +typedef struct _zend_resource zend_resource; +typedef struct _zend_reference zend_reference; +typedef struct _zend_ast_ref zend_ast_ref; +typedef struct _zend_ast zend_ast; +typedef int (*compare_func_t)(const void *, const void *); +typedef void (*swap_func_t)(void *, void *); +typedef void (*sort_func_t)(void *, size_t, size_t, compare_func_t, swap_func_t); +typedef void (*dtor_func_t)(zval *pDest); +typedef void (*copy_ctor_func_t)(zval *pElement); +typedef union _zend_value { + zend_long lval; + double dval; + zend_refcounted *counted; + zend_string *str; + zend_array *arr; + zend_object *obj; + zend_resource *res; + zend_reference *ref; + zend_ast_ref *ast; + zval *zv; + void *ptr; + zend_class_entry *ce; + zend_function *func; + struct { + uint32_t w1; + uint32_t w2; + } ww; +} zend_value; +struct _zval_struct { + zend_value value; + union { + uint32_t type_info; + struct { + zend_uchar type; zend_uchar type_flags; union { uint16_t extra; } u; + } v; + } u1; + union { + uint32_t next; + uint32_t cache_slot; + uint32_t opline_num; + uint32_t lineno; + uint32_t num_args; + uint32_t fe_pos; + uint32_t fe_iter_idx; + uint32_t access_flags; + uint32_t property_guard; + uint32_t constant_flags; + uint32_t extra; + } u2; +}; +typedef struct _zend_refcounted_h { + uint32_t refcount; + union { + uint32_t type_info; + } u; +} zend_refcounted_h; +struct _zend_refcounted { + zend_refcounted_h gc; +}; +struct _zend_string { + zend_refcounted_h gc; + zend_ulong h; + size_t len; + char val[1]; +}; +typedef struct _Bucket { + zval val; + zend_ulong h; + zend_string *key; +} Bucket; +typedef struct _zend_array HashTable; +struct _zend_array { + zend_refcounted_h gc; + union { + struct { + zend_uchar flags; zend_uchar _unused; zend_uchar nIteratorsCount; zend_uchar _unused2; + } v; + uint32_t flags; + } u; + uint32_t nTableMask; + Bucket *arData; + uint32_t nNumUsed; + uint32_t nNumOfElements; + uint32_t nTableSize; + uint32_t nInternalPointer; + zend_long nNextFreeElement; + dtor_func_t pDestructor; +}; +typedef uint32_t HashPosition; +typedef struct _HashTableIterator { + HashTable *ht; + HashPosition pos; +} HashTableIterator; +struct _zend_object { + zend_refcounted_h gc; + uint32_t handle; + zend_class_entry *ce; + const zend_object_handlers *handlers; + HashTable *properties; + zval properties_table[1]; +}; +struct _zend_resource { + zend_refcounted_h gc; + int handle; + int type; + void *ptr; +}; +typedef struct { + size_t num; + size_t num_allocated; + struct _zend_property_info *ptr[1]; +} zend_property_info_list; +typedef union { + struct _zend_property_info *ptr; + uintptr_t list; +} zend_property_info_source_list; +struct _zend_reference { + zend_refcounted_h gc; + zval val; + zend_property_info_source_list sources; +}; +struct _zend_ast_ref { + zend_refcounted_h gc; +}; +typedef uint16_t zend_ast_kind; +typedef uint16_t zend_ast_attr; +struct _zend_ast { + zend_ast_kind kind; + zend_ast_attr attr; + uint32_t lineno; + zend_ast *child[1]; +}; +typedef struct _zend_ast_list { + zend_ast_kind kind; + zend_ast_attr attr; + uint32_t lineno; + uint32_t children; + zend_ast *child[1]; +} zend_ast_list; +typedef struct _zend_ast_zval { + zend_ast_kind kind; + zend_ast_attr attr; + zval val; +} zend_ast_zval; +typedef struct _zend_ast_decl { + zend_ast_kind kind; + zend_ast_attr attr; + uint32_t start_lineno; + uint32_t end_lineno; + uint32_t flags; + unsigned char *lex_pos; + zend_string *doc_comment; + zend_string *name; + zend_ast *child[5]; +} zend_ast_decl; +typedef void (*zend_ast_process_t)(zend_ast *ast); +typedef intptr_t zend_intptr_t; +typedef uintptr_t zend_uintptr_t; +typedef struct _zend_arena zend_arena; +struct _zend_arena { + char *ptr; + char *end; + zend_arena *prev; +}; +typedef struct _zend_op_array zend_op_array; +typedef struct _zend_op zend_op; +typedef union _znode_op { + uint32_t constant; + uint32_t var; + uint32_t num; + uint32_t opline_num; + uint32_t jmp_offset; +} znode_op; +typedef struct _znode { + zend_uchar op_type; + zend_uchar flag; + union { + znode_op op; + zval constant; + } u; +} znode; +typedef struct _zend_ast_znode { + zend_ast_kind kind; + zend_ast_attr attr; + uint32_t lineno; + znode node; +} zend_ast_znode; +typedef struct _zend_declarables { + zend_long ticks; +} zend_declarables; +typedef struct _zend_file_context { + zend_declarables declarables; + zend_string *current_namespace; + zend_bool in_namespace; + zend_bool has_bracketed_namespaces; + HashTable *imports; + HashTable *imports_function; + HashTable *imports_const; + HashTable seen_symbols; +} zend_file_context; +typedef struct { + uint32_t offset; + uint32_t len; +} zend_lexer_ident_ref; +typedef union _zend_parser_stack_elem { + zend_ast *ast; + zend_string *str; + zend_ulong num; + unsigned char *ptr; + zend_lexer_ident_ref ident; +} zend_parser_stack_elem; +typedef int (*user_opcode_handler_t) (zend_execute_data *execute_data); +struct _zend_op { + const void *handler; + znode_op op1; + znode_op op2; + znode_op result; + uint32_t extended_value; + uint32_t lineno; + zend_uchar opcode; + zend_uchar op1_type; + zend_uchar op2_type; + zend_uchar result_type; +}; +typedef struct _zend_brk_cont_element { + int start; + int cont; + int brk; + int parent; + zend_bool is_switch; +} zend_brk_cont_element; +typedef struct _zend_label { + int brk_cont; + uint32_t opline_num; +} zend_label; +typedef struct _zend_try_catch_element { + uint32_t try_op; + uint32_t catch_op; + uint32_t finally_op; + uint32_t finally_end; +} zend_try_catch_element; +typedef struct _zend_live_range { + uint32_t var; + uint32_t start; + uint32_t end; +} zend_live_range; +typedef struct _zend_oparray_context { + uint32_t opcodes_size; + int vars_size; + int literals_size; + uint32_t fast_call_var; + uint32_t try_catch_offset; + int current_brk_cont; + int last_brk_cont; + zend_brk_cont_element *brk_cont_array; + HashTable *labels; +} zend_oparray_context; +typedef struct _zend_property_info { + uint32_t offset; + uint32_t flags; + zend_string *name; + zend_string *doc_comment; + HashTable *attributes; + zend_class_entry *ce; + zend_type type; +} zend_property_info; +typedef struct _zend_class_constant { + zval value; + zend_string *doc_comment; + HashTable *attributes; + zend_class_entry *ce; +} zend_class_constant; +typedef struct _zend_internal_arg_info { + const char *name; + zend_type type; + const char *default_value; +} zend_internal_arg_info; +typedef struct _zend_arg_info { + zend_string *name; + zend_type type; + zend_string *default_value; +} zend_arg_info; +typedef struct _zend_internal_function_info { + zend_uintptr_t required_num_args; + zend_type type; + const char *default_value; +} zend_internal_function_info; +struct _zend_op_array { + zend_uchar type; + zend_uchar arg_flags[3]; + uint32_t fn_flags; + zend_string *function_name; + zend_class_entry *scope; + zend_function *prototype; + uint32_t num_args; + uint32_t required_num_args; + zend_arg_info *arg_info; + HashTable *attributes; + int cache_size; + int last_var; + uint32_t T; + uint32_t last; + zend_op *opcodes; + void ** * run_time_cache__ptr; + HashTable * * static_variables_ptr__ptr; + HashTable *static_variables; + zend_string **vars; + uint32_t *refcount; + int last_live_range; + int last_try_catch; + zend_live_range *live_range; + zend_try_catch_element *try_catch_array; + zend_string *filename; + uint32_t line_start; + uint32_t line_end; + zend_string *doc_comment; + int last_literal; + zval *literals; + void *reserved[6]; +}; +typedef void ( *zif_handler)(zend_execute_data *execute_data, zval *return_value); +typedef struct _zend_internal_function { + zend_uchar type; + zend_uchar arg_flags[3]; + uint32_t fn_flags; + zend_string* function_name; + zend_class_entry *scope; + zend_function *prototype; + uint32_t num_args; + uint32_t required_num_args; + zend_internal_arg_info *arg_info; + HashTable *attributes; + zif_handler handler; + struct _zend_module_entry *module; + void *reserved[6]; +} zend_internal_function; +union _zend_function { + zend_uchar type; + uint32_t quick_arg_flags; + struct { + zend_uchar type; + zend_uchar arg_flags[3]; + uint32_t fn_flags; + zend_string *function_name; + zend_class_entry *scope; + zend_function *prototype; + uint32_t num_args; + uint32_t required_num_args; + zend_arg_info *arg_info; + HashTable *attributes; + } common; + zend_op_array op_array; + zend_internal_function internal_function; +}; +struct _zend_execute_data { + const zend_op *opline; + zend_execute_data *call; + zval *return_value; + zend_function *func; + zval This; + zend_execute_data *prev_execute_data; + zend_array *symbol_table; + void **run_time_cache; + zend_array *extra_named_params; +}; +typedef struct _zend_closure { + zend_object std; + zend_function func; + zval this_ptr; + zend_class_entry *called_scope; + zif_handler orig_internal_handler; +} zend_closure; +extern const zend_object_handlers std_object_handlers; +typedef zval *(*zend_object_read_property_t)(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv); +typedef zval *(*zend_object_read_dimension_t)(zend_object *object, zval *offset, int type, zval *rv); +typedef zval *(*zend_object_write_property_t)(zend_object *object, zend_string *member, zval *value, void **cache_slot); +typedef void (*zend_object_write_dimension_t)(zend_object *object, zval *offset, zval *value); +typedef zval *(*zend_object_get_property_ptr_ptr_t)(zend_object *object, zend_string *member, int type, void **cache_slot); +typedef int (*zend_object_has_property_t)(zend_object *object, zend_string *member, int has_set_exists, void **cache_slot); +typedef int (*zend_object_has_dimension_t)(zend_object *object, zval *member, int check_empty); +typedef void (*zend_object_unset_property_t)(zend_object *object, zend_string *member, void **cache_slot); +typedef void (*zend_object_unset_dimension_t)(zend_object *object, zval *offset); +typedef HashTable *(*zend_object_get_properties_t)(zend_object *object); +typedef HashTable *(*zend_object_get_debug_info_t)(zend_object *object, int *is_temp); +typedef enum _zend_prop_purpose { + ZEND_PROP_PURPOSE_DEBUG, + ZEND_PROP_PURPOSE_ARRAY_CAST, + ZEND_PROP_PURPOSE_SERIALIZE, + ZEND_PROP_PURPOSE_VAR_EXPORT, + ZEND_PROP_PURPOSE_JSON, + _ZEND_PROP_PURPOSE_NON_EXHAUSTIVE_ENUM +} zend_prop_purpose; +typedef zend_array *(*zend_object_get_properties_for_t)(zend_object *object, zend_prop_purpose purpose); +typedef zend_function *(*zend_object_get_method_t)(zend_object **object, zend_string *method, const zval *key); +typedef zend_function *(*zend_object_get_constructor_t)(zend_object *object); +typedef void (*zend_object_dtor_obj_t)(zend_object *object); +typedef void (*zend_object_free_obj_t)(zend_object *object); +typedef zend_object* (*zend_object_clone_obj_t)(zend_object *object); +typedef zend_string *(*zend_object_get_class_name_t)(const zend_object *object); +typedef int (*zend_object_compare_t)(zval *object1, zval *object2); +typedef int (*zend_object_cast_t)(zend_object *readobj, zval *retval, int type); +typedef int (*zend_object_count_elements_t)(zend_object *object, zend_long *count); +typedef int (*zend_object_get_closure_t)(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, zend_bool check_only); +typedef HashTable *(*zend_object_get_gc_t)(zend_object *object, zval **table, int *n); +typedef int (*zend_object_do_operation_t)(zend_uchar opcode, zval *result, zval *op1, zval *op2); +struct _zend_object_handlers { + int offset; + zend_object_free_obj_t free_obj; + zend_object_dtor_obj_t dtor_obj; + zend_object_clone_obj_t clone_obj; + zend_object_read_property_t read_property; + zend_object_write_property_t write_property; + zend_object_read_dimension_t read_dimension; + zend_object_write_dimension_t write_dimension; + zend_object_get_property_ptr_ptr_t get_property_ptr_ptr; + zend_object_has_property_t has_property; + zend_object_unset_property_t unset_property; + zend_object_has_dimension_t has_dimension; + zend_object_unset_dimension_t unset_dimension; + zend_object_get_properties_t get_properties; + zend_object_get_method_t get_method; + zend_object_get_constructor_t get_constructor; + zend_object_get_class_name_t get_class_name; + zend_object_cast_t cast_object; + zend_object_count_elements_t count_elements; + zend_object_get_debug_info_t get_debug_info; + zend_object_get_closure_t get_closure; + zend_object_get_gc_t get_gc; + zend_object_do_operation_t do_operation; + zend_object_compare_t compare; + zend_object_get_properties_for_t get_properties_for; +}; +typedef struct _zend_llist_element { + struct _zend_llist_element *next; + struct _zend_llist_element *prev; + char data[1]; +} zend_llist_element; +typedef void (*llist_dtor_func_t)(void *); +typedef int (*llist_compare_func_t)(const zend_llist_element **, const zend_llist_element **); +typedef void (*llist_apply_with_args_func_t)(void *data, int num_args, va_list args); +typedef void (*llist_apply_with_arg_func_t)(void *data, void *arg); +typedef void (*llist_apply_func_t)(void *); +typedef struct _zend_llist { + zend_llist_element *head; + zend_llist_element *tail; + size_t count; + size_t size; + llist_dtor_func_t dtor; + unsigned char persistent; + zend_llist_element *traverse_ptr; +} zend_llist; +typedef zend_llist_element* zend_llist_position; +typedef struct _zend_encoding zend_encoding; +typedef struct _zend_stack { + int size, top, max; + void *elements; +} zend_stack; +typedef struct _zend_vm_stack *zend_vm_stack; +typedef struct _zend_ini_entry zend_ini_entry; +typedef enum { + ON_TOKEN, + ON_FEEDBACK, + ON_STOP +} zend_php_scanner_event; +struct _zend_vm_stack { + zval *top; + zval *end; + zend_vm_stack prev; +}; +typedef struct _zend_function_entry { + const char *fname; + zif_handler handler; + const struct _zend_internal_arg_info *arg_info; + uint32_t num_args; + uint32_t flags; +} zend_function_entry; +typedef struct _zend_fcall_info { + size_t size; + zval function_name; + zval *retval; + zval *params; + zend_object *object; + uint32_t param_count; + HashTable *named_params; +} zend_fcall_info; +typedef struct _zend_fcall_info_cache { + zend_function *function_handler; + zend_class_entry *calling_scope; + zend_class_entry *called_scope; + zend_object *object; +} zend_fcall_info_cache; +typedef struct _zend_object_iterator zend_object_iterator; +typedef struct _zend_object_iterator_funcs { + void (*dtor)(zend_object_iterator *iter); + int (*valid)(zend_object_iterator *iter); + zval *(*get_current_data)(zend_object_iterator *iter); + void (*get_current_key)(zend_object_iterator *iter, zval *key); + void (*move_forward)(zend_object_iterator *iter); + void (*rewind)(zend_object_iterator *iter); + void (*invalidate_current)(zend_object_iterator *iter); + HashTable *(*get_gc)(zend_object_iterator *iter, zval **table, int *n); +} zend_object_iterator_funcs; +struct _zend_object_iterator { + zend_object std; + zval data; + const zend_object_iterator_funcs *funcs; + zend_ulong index; +}; +typedef struct _zend_class_iterator_funcs { + zend_function *zf_new_iterator; + zend_function *zf_valid; + zend_function *zf_current; + zend_function *zf_key; + zend_function *zf_next; + zend_function *zf_rewind; +} zend_class_iterator_funcs; +struct _zend_serialize_data; +struct _zend_unserialize_data; +typedef struct _zend_serialize_data zend_serialize_data; +typedef struct _zend_unserialize_data zend_unserialize_data; +typedef struct _zend_class_name { + zend_string *name; + zend_string *lc_name; +} zend_class_name; +typedef struct _zend_trait_method_reference { + zend_string *method_name; + zend_string *class_name; +} zend_trait_method_reference; +typedef struct _zend_trait_precedence { + zend_trait_method_reference trait_method; + uint32_t num_excludes; + zend_string *exclude_class_names[1]; +} zend_trait_precedence; +typedef struct _zend_trait_alias { + zend_trait_method_reference trait_method; + zend_string *alias; + uint32_t modifiers; +} zend_trait_alias; +struct _zend_class_entry { + char type; + zend_string *name; + union { + zend_class_entry *parent; + zend_string *parent_name; + }; + int refcount; + uint32_t ce_flags; + int default_properties_count; + int default_static_members_count; + zval *default_properties_table; + zval *default_static_members_table; + zval * * static_members_table__ptr; + HashTable function_table; + HashTable properties_info; + HashTable constants_table; + struct _zend_property_info **properties_info_table; + zend_function *constructor; + zend_function *destructor; + zend_function *clone; + zend_function *__get; + zend_function *__set; + zend_function *__unset; + zend_function *__isset; + zend_function *__call; + zend_function *__callstatic; + zend_function *__tostring; + zend_function *__debugInfo; + zend_function *__serialize; + zend_function *__unserialize; + zend_class_iterator_funcs *iterator_funcs_ptr; + union { + zend_object* (*create_object)(zend_class_entry *class_type); + int (*interface_gets_implemented)(zend_class_entry *iface, zend_class_entry *class_type); + }; + zend_object_iterator *(*get_iterator)(zend_class_entry *ce, zval *object, int by_ref); + zend_function *(*get_static_method)(zend_class_entry *ce, zend_string* method); + int (*serialize)(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data); + int (*unserialize)(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data); + uint32_t num_interfaces; + uint32_t num_traits; + union { + zend_class_entry **interfaces; + zend_class_name *interface_names; + }; + zend_class_name *trait_names; + zend_trait_alias **trait_aliases; + zend_trait_precedence **trait_precedences; + HashTable *attributes; + union { + struct { + zend_string *filename; + uint32_t line_start; + uint32_t line_end; + zend_string *doc_comment; + } user; + struct { + const struct _zend_function_entry *builtin_functions; + struct _zend_module_entry *module; + } internal; + } info; +}; +typedef enum { + EH_NORMAL = 0, + EH_THROW +} zend_error_handling_t; +typedef struct { + zend_error_handling_t handling; + zend_class_entry *exception; +} zend_error_handling; +typedef struct _zend_objects_store { + zend_object **object_buckets; + uint32_t top; + uint32_t size; + int free_list_head; +} zend_objects_store; +struct _zend_ini_entry { + zend_string *name; + int (*on_modify)(zend_ini_entry *entry, zend_string *new_value, void *mh_arg1, void *mh_arg2, void *mh_arg3, int stage); + void *mh_arg1; + void *mh_arg2; + void *mh_arg3; + zend_string *value; + zend_string *orig_value; + void (*displayer)(zend_ini_entry *ini_entry, int type); + int module_number; + uint8_t modifiable; + uint8_t orig_modifiable; + uint8_t modified; +}; +typedef struct _zend_module_entry zend_module_entry; +typedef struct _zend_module_dep zend_module_dep; +typedef ZEND_RESULT_CODE zend_result; +struct _zend_module_entry { + unsigned short size; + unsigned int zend_api; + unsigned char zend_debug; + unsigned char zts; + const struct _zend_ini_entry *ini_entry; + const struct _zend_module_dep *deps; + const char *name; + const struct _zend_function_entry *functions; + zend_result (*module_startup_func)(int type, int module_number); + zend_result (*module_shutdown_func)(int type, int module_number); + zend_result (*request_startup_func)(int type, int module_number); + zend_result (*request_shutdown_func)(int type, int module_number); + void (*info_func)(zend_module_entry *zend_module); + const char *version; + size_t globals_size; + void* globals_ptr; + void (*globals_ctor)(void *global); + void (*globals_dtor)(void *global); + zend_result (*post_deactivate_func)(void); + int module_started; + unsigned char type; + void *handle; + int module_number; + const char *build_id; +}; +struct _zend_module_dep { + const char *name; + const char *rel; + const char *version; + unsigned char type; +}; +typedef struct _zend_gc_status { + uint32_t runs; + uint32_t collected; + uint32_t threshold; + uint32_t num_roots; +} zend_gc_status; +typedef struct { + zval *cur; + zval *end; + zval *start; +} zend_get_gc_buffer; +struct _zend_compiler_globals { + zend_stack loop_var_stack; + zend_class_entry *active_class_entry; + zend_string *compiled_filename; + int zend_lineno; + zend_op_array *active_op_array; + HashTable *function_table; + HashTable *class_table; + HashTable *auto_globals; + zend_uchar parse_error; + zend_bool in_compilation; + zend_bool short_tags; + zend_bool unclean_shutdown; + zend_bool ini_parser_unbuffered_errors; + zend_llist open_files; + struct _zend_ini_parser_param *ini_parser_param; + zend_bool skip_shebang; + zend_bool increment_lineno; + zend_string *doc_comment; + uint32_t extra_fn_flags; + uint32_t compiler_options; + zend_oparray_context context; + zend_file_context file_context; + zend_arena *arena; + HashTable interned_strings; + const zend_encoding **script_encoding_list; + size_t script_encoding_list_size; + zend_bool multibyte; + zend_bool detect_unicode; + zend_bool encoding_declared; + zend_ast *ast; + zend_arena *ast_arena; + zend_stack delayed_oplines_stack; + HashTable *memoized_exprs; + int memoize_mode; + void *map_ptr_base; + size_t map_ptr_size; + size_t map_ptr_last; + HashTable *delayed_variance_obligations; + HashTable *delayed_autoloads; + uint32_t rtd_key_counter; + zend_stack short_circuiting_opnums; +}; +typedef void jmp_buf; +struct _zend_executor_globals { + zval uninitialized_zval; + zval error_zval; + zend_array *symtable_cache[32]; + zend_array **symtable_cache_limit; + zend_array **symtable_cache_ptr; + zend_array symbol_table; + HashTable included_files; + jmp_buf *bailout; + int error_reporting; + int exit_status; + HashTable *function_table; + HashTable *class_table; + HashTable *zend_constants; + zval *vm_stack_top; + zval *vm_stack_end; + zend_vm_stack vm_stack; + size_t vm_stack_page_size; + struct _zend_execute_data *current_execute_data; + zend_class_entry *fake_scope; + uint32_t jit_trace_num; + zend_long precision; + int ticks_count; + uint32_t persistent_constants_count; + uint32_t persistent_functions_count; + uint32_t persistent_classes_count; + HashTable *in_autoload; + zend_bool full_tables_cleanup; + zend_bool no_extensions; + zend_bool vm_interrupt; + zend_bool timed_out; + zend_long hard_timeout; + HashTable regular_list; + HashTable persistent_list; + int user_error_handler_error_reporting; + zval user_error_handler; + zval user_exception_handler; + zend_stack user_error_handlers_error_reporting; + zend_stack user_error_handlers; + zend_stack user_exception_handlers; + zend_error_handling_t error_handling; + zend_class_entry *exception_class; + zend_long timeout_seconds; + int lambda_count; + HashTable *ini_directives; + HashTable *modified_ini_directives; + zend_ini_entry *error_reporting_ini_entry; + zend_objects_store objects_store; + zend_object *exception, *prev_exception; + const zend_op *opline_before_exception; + zend_op exception_op[3]; + struct _zend_module_entry *current_module; + zend_bool active; + zend_uchar flags; + zend_long assertions; + uint32_t ht_iterators_count; + uint32_t ht_iterators_used; + HashTableIterator *ht_iterators; + HashTableIterator ht_iterators_slots[16]; + void *saved_fpu_cw_ptr; + zend_function trampoline; + zend_op call_trampoline_op; + HashTable weakrefs; + zend_bool exception_ignore_args; + zend_long exception_string_param_max_len; + zend_get_gc_buffer get_gc_buffer; + void *reserved[6]; +}; +typedef struct _zend_executor_globals zend_executor_globals; +extern zend_executor_globals executor_globals; +extern struct _zend_compiler_globals compiler_globals; +typedef struct _IO_FILE FILE; +typedef size_t (*zend_stream_fsizer_t)(void* handle); +typedef ssize_t (*zend_stream_reader_t)(void* handle, char *buf, size_t len); +typedef void (*zend_stream_closer_t)(void* handle); +typedef enum { + ZEND_HANDLE_FILENAME, + ZEND_HANDLE_FP, + ZEND_HANDLE_STREAM +} zend_stream_type; +typedef struct _zend_stream { + void *handle; + int isatty; + zend_stream_reader_t reader; + zend_stream_fsizer_t fsizer; + zend_stream_closer_t closer; +} zend_stream; +typedef struct _zend_file_handle { + union { + FILE *fp; + zend_stream stream; + } handle; + const char *filename; + zend_string *opened_path; + zend_stream_type type; + zend_bool free_filename; + char *buf; + size_t len; +} zend_file_handle; +typedef struct _zend_ptr_stack { + int top, max; + void **elements; + void **top_element; + zend_bool persistent; +} zend_ptr_stack; +typedef size_t (*zend_encoding_filter)(unsigned char **str, size_t *str_length, const unsigned char *buf, size_t length); +typedef struct _zend_lex_state { + unsigned int yy_leng; + unsigned char *yy_start; + unsigned char *yy_text; + unsigned char *yy_cursor; + unsigned char *yy_marker; + unsigned char *yy_limit; + int yy_state; + zend_stack state_stack; + zend_ptr_stack heredoc_label_stack; + zend_stack nest_location_stack; + zend_file_handle *in; + uint32_t lineno; + zend_string *filename; + unsigned char *script_org; + size_t script_org_size; + unsigned char *script_filtered; + size_t script_filtered_size; + zend_encoding_filter input_filter; + zend_encoding_filter output_filter; + const zend_encoding *script_encoding; + void (*on_event)( + zend_php_scanner_event event, int token, int line, + const char *text, size_t length, void *context); + void *on_event_context; + zend_ast *ast; + zend_arena *ast_arena; +} zend_lex_state; +typedef struct _zend_heredoc_label { + char *label; + int length; + int indentation; + zend_bool indentation_uses_spaces; +} zend_heredoc_label; +extern zend_ast_process_t zend_ast_process; +extern HashTable module_registry; +zend_result zend_hash_del(HashTable *ht, zend_string *key); +zval* zend_hash_find(const HashTable *ht, zend_string *key); +zval* zend_hash_add_or_update(HashTable *ht, zend_string *key, zval *pData, uint32_t flag); +int zend_set_user_opcode_handler(zend_uchar opcode, user_opcode_handler_t handler); +user_opcode_handler_t zend_get_user_opcode_handler(zend_uchar opcode); +void zend_do_inheritance_ex(zend_class_entry *ce, zend_class_entry *parent_ce, zend_bool checked); +zend_object* zend_objects_new(zend_class_entry *ce); +void zend_object_std_init(zend_object *object, zend_class_entry *ce); +void object_properties_init(zend_object *object, zend_class_entry *class_type); +void zend_save_lexical_state(zend_lex_state *lex_state); +void zend_restore_lexical_state(zend_lex_state *lex_state); +void zend_prepare_string_for_scanning(zval *str, const char *filename); +zend_result zend_lex_tstring(zval *zv, zend_lexer_ident_ref ident_ref); +int zendparse(void); +void zend_ast_destroy(zend_ast *ast); +zend_ast * zend_ast_create_list_0(zend_ast_kind kind); +zend_ast * zend_ast_list_add(zend_ast *list, zend_ast *op); +zend_ast * zend_ast_create_zval_ex(zval *zv, zend_ast_attr attr); +zend_ast * zend_ast_create_0(zend_ast_kind kind); +zend_ast * zend_ast_create_1(zend_ast_kind kind, zend_ast *child); +zend_ast * zend_ast_create_2(zend_ast_kind kind, zend_ast *child1, zend_ast *child2); +zend_ast * zend_ast_create_3(zend_ast_kind kind, zend_ast *child1, zend_ast *child2, zend_ast *child3); +zend_ast * zend_ast_create_4(zend_ast_kind kind, zend_ast *child1, zend_ast *child2, zend_ast *child3, zend_ast *child4); +zend_ast *zend_ast_create_decl( + zend_ast_kind kind, uint32_t flags, uint32_t start_lineno, zend_string *doc_comment, + zend_string *name, zend_ast *child0, zend_ast *child1, zend_ast *child2, zend_ast *child3, zend_ast *child4 +); +zend_module_entry* zend_register_module_ex(zend_module_entry *module); +zend_result zend_startup_module_ex(zend_module_entry *module); diff --git a/include/engine_8_0_x64_zts.h b/include/engine_8_0_x64_zts.h new file mode 100644 index 0000000..b8c2350 --- /dev/null +++ b/include/engine_8_0_x64_zts.h @@ -0,0 +1,913 @@ +#define FFI_SCOPE "ZEngine" +#define FFI_LIB "ZEND_LIBRARY_NAME" +typedef int64_t zend_long; +typedef uint64_t zend_ulong; +typedef int64_t zend_off_t; +typedef _Bool zend_bool; +typedef unsigned char zend_uchar; +typedef struct { + void *ptr; + uint32_t type_mask; +} zend_type; +typedef enum { + SUCCESS = 0, + FAILURE = -1, +} ZEND_RESULT_CODE; +typedef struct _zend_object_handlers zend_object_handlers; +typedef struct _zend_class_entry zend_class_entry; +typedef union _zend_function zend_function; +typedef struct _zend_execute_data zend_execute_data; +typedef struct _zval_struct zval; +typedef struct _zend_refcounted zend_refcounted; +typedef struct _zend_string zend_string; +typedef struct _zend_array zend_array; +typedef struct _zend_object zend_object; +typedef struct _zend_resource zend_resource; +typedef struct _zend_reference zend_reference; +typedef struct _zend_ast_ref zend_ast_ref; +typedef struct _zend_ast zend_ast; +typedef int (*compare_func_t)(const void *, const void *); +typedef void (*swap_func_t)(void *, void *); +typedef void (*sort_func_t)(void *, size_t, size_t, compare_func_t, swap_func_t); +typedef void (*dtor_func_t)(zval *pDest); +typedef void (*copy_ctor_func_t)(zval *pElement); +typedef union _zend_value { + zend_long lval; + double dval; + zend_refcounted *counted; + zend_string *str; + zend_array *arr; + zend_object *obj; + zend_resource *res; + zend_reference *ref; + zend_ast_ref *ast; + zval *zv; + void *ptr; + zend_class_entry *ce; + zend_function *func; + struct { + uint32_t w1; + uint32_t w2; + } ww; +} zend_value; +struct _zval_struct { + zend_value value; + union { + uint32_t type_info; + struct { + zend_uchar type; zend_uchar type_flags; union { uint16_t extra; } u; + } v; + } u1; + union { + uint32_t next; + uint32_t cache_slot; + uint32_t opline_num; + uint32_t lineno; + uint32_t num_args; + uint32_t fe_pos; + uint32_t fe_iter_idx; + uint32_t access_flags; + uint32_t property_guard; + uint32_t constant_flags; + uint32_t extra; + } u2; +}; +typedef struct _zend_refcounted_h { + uint32_t refcount; + union { + uint32_t type_info; + } u; +} zend_refcounted_h; +struct _zend_refcounted { + zend_refcounted_h gc; +}; +struct _zend_string { + zend_refcounted_h gc; + zend_ulong h; + size_t len; + char val[1]; +}; +typedef struct _Bucket { + zval val; + zend_ulong h; + zend_string *key; +} Bucket; +typedef struct _zend_array HashTable; +struct _zend_array { + zend_refcounted_h gc; + union { + struct { + zend_uchar flags; zend_uchar _unused; zend_uchar nIteratorsCount; zend_uchar _unused2; + } v; + uint32_t flags; + } u; + uint32_t nTableMask; + Bucket *arData; + uint32_t nNumUsed; + uint32_t nNumOfElements; + uint32_t nTableSize; + uint32_t nInternalPointer; + zend_long nNextFreeElement; + dtor_func_t pDestructor; +}; +typedef uint32_t HashPosition; +typedef struct _HashTableIterator { + HashTable *ht; + HashPosition pos; +} HashTableIterator; +struct _zend_object { + zend_refcounted_h gc; + uint32_t handle; + zend_class_entry *ce; + const zend_object_handlers *handlers; + HashTable *properties; + zval properties_table[1]; +}; +struct _zend_resource { + zend_refcounted_h gc; + int handle; + int type; + void *ptr; +}; +typedef struct { + size_t num; + size_t num_allocated; + struct _zend_property_info *ptr[1]; +} zend_property_info_list; +typedef union { + struct _zend_property_info *ptr; + uintptr_t list; +} zend_property_info_source_list; +struct _zend_reference { + zend_refcounted_h gc; + zval val; + zend_property_info_source_list sources; +}; +struct _zend_ast_ref { + zend_refcounted_h gc; +}; +typedef uint16_t zend_ast_kind; +typedef uint16_t zend_ast_attr; +struct _zend_ast { + zend_ast_kind kind; + zend_ast_attr attr; + uint32_t lineno; + zend_ast *child[1]; +}; +typedef struct _zend_ast_list { + zend_ast_kind kind; + zend_ast_attr attr; + uint32_t lineno; + uint32_t children; + zend_ast *child[1]; +} zend_ast_list; +typedef struct _zend_ast_zval { + zend_ast_kind kind; + zend_ast_attr attr; + zval val; +} zend_ast_zval; +typedef struct _zend_ast_decl { + zend_ast_kind kind; + zend_ast_attr attr; + uint32_t start_lineno; + uint32_t end_lineno; + uint32_t flags; + unsigned char *lex_pos; + zend_string *doc_comment; + zend_string *name; + zend_ast *child[5]; +} zend_ast_decl; +typedef void (*zend_ast_process_t)(zend_ast *ast); +typedef intptr_t zend_intptr_t; +typedef uintptr_t zend_uintptr_t; +typedef struct _zend_arena zend_arena; +struct _zend_arena { + char *ptr; + char *end; + zend_arena *prev; +}; +typedef struct _zend_op_array zend_op_array; +typedef struct _zend_op zend_op; +typedef union _znode_op { + uint32_t constant; + uint32_t var; + uint32_t num; + uint32_t opline_num; + uint32_t jmp_offset; +} znode_op; +typedef struct _znode { + zend_uchar op_type; + zend_uchar flag; + union { + znode_op op; + zval constant; + } u; +} znode; +typedef struct _zend_ast_znode { + zend_ast_kind kind; + zend_ast_attr attr; + uint32_t lineno; + znode node; +} zend_ast_znode; +typedef struct _zend_declarables { + zend_long ticks; +} zend_declarables; +typedef struct _zend_file_context { + zend_declarables declarables; + zend_string *current_namespace; + zend_bool in_namespace; + zend_bool has_bracketed_namespaces; + HashTable *imports; + HashTable *imports_function; + HashTable *imports_const; + HashTable seen_symbols; +} zend_file_context; +typedef struct { + uint32_t offset; + uint32_t len; +} zend_lexer_ident_ref; +typedef union _zend_parser_stack_elem { + zend_ast *ast; + zend_string *str; + zend_ulong num; + unsigned char *ptr; + zend_lexer_ident_ref ident; +} zend_parser_stack_elem; +typedef int (*user_opcode_handler_t) (zend_execute_data *execute_data); +struct _zend_op { + const void *handler; + znode_op op1; + znode_op op2; + znode_op result; + uint32_t extended_value; + uint32_t lineno; + zend_uchar opcode; + zend_uchar op1_type; + zend_uchar op2_type; + zend_uchar result_type; +}; +typedef struct _zend_brk_cont_element { + int start; + int cont; + int brk; + int parent; + zend_bool is_switch; +} zend_brk_cont_element; +typedef struct _zend_label { + int brk_cont; + uint32_t opline_num; +} zend_label; +typedef struct _zend_try_catch_element { + uint32_t try_op; + uint32_t catch_op; + uint32_t finally_op; + uint32_t finally_end; +} zend_try_catch_element; +typedef struct _zend_live_range { + uint32_t var; + uint32_t start; + uint32_t end; +} zend_live_range; +typedef struct _zend_oparray_context { + uint32_t opcodes_size; + int vars_size; + int literals_size; + uint32_t fast_call_var; + uint32_t try_catch_offset; + int current_brk_cont; + int last_brk_cont; + zend_brk_cont_element *brk_cont_array; + HashTable *labels; +} zend_oparray_context; +typedef struct _zend_property_info { + uint32_t offset; + uint32_t flags; + zend_string *name; + zend_string *doc_comment; + HashTable *attributes; + zend_class_entry *ce; + zend_type type; +} zend_property_info; +typedef struct _zend_class_constant { + zval value; + zend_string *doc_comment; + HashTable *attributes; + zend_class_entry *ce; +} zend_class_constant; +typedef struct _zend_internal_arg_info { + const char *name; + zend_type type; + const char *default_value; +} zend_internal_arg_info; +typedef struct _zend_arg_info { + zend_string *name; + zend_type type; + zend_string *default_value; +} zend_arg_info; +typedef struct _zend_internal_function_info { + zend_uintptr_t required_num_args; + zend_type type; + const char *default_value; +} zend_internal_function_info; +struct _zend_op_array { + zend_uchar type; + zend_uchar arg_flags[3]; + uint32_t fn_flags; + zend_string *function_name; + zend_class_entry *scope; + zend_function *prototype; + uint32_t num_args; + uint32_t required_num_args; + zend_arg_info *arg_info; + HashTable *attributes; + int cache_size; + int last_var; + uint32_t T; + uint32_t last; + zend_op *opcodes; + void ** * run_time_cache__ptr; + HashTable * * static_variables_ptr__ptr; + HashTable *static_variables; + zend_string **vars; + uint32_t *refcount; + int last_live_range; + int last_try_catch; + zend_live_range *live_range; + zend_try_catch_element *try_catch_array; + zend_string *filename; + uint32_t line_start; + uint32_t line_end; + zend_string *doc_comment; + int last_literal; + zval *literals; + void *reserved[6]; +}; +typedef void ( *zif_handler)(zend_execute_data *execute_data, zval *return_value); +typedef struct _zend_internal_function { + zend_uchar type; + zend_uchar arg_flags[3]; + uint32_t fn_flags; + zend_string* function_name; + zend_class_entry *scope; + zend_function *prototype; + uint32_t num_args; + uint32_t required_num_args; + zend_internal_arg_info *arg_info; + HashTable *attributes; + zif_handler handler; + struct _zend_module_entry *module; + void *reserved[6]; +} zend_internal_function; +union _zend_function { + zend_uchar type; + uint32_t quick_arg_flags; + struct { + zend_uchar type; + zend_uchar arg_flags[3]; + uint32_t fn_flags; + zend_string *function_name; + zend_class_entry *scope; + zend_function *prototype; + uint32_t num_args; + uint32_t required_num_args; + zend_arg_info *arg_info; + HashTable *attributes; + } common; + zend_op_array op_array; + zend_internal_function internal_function; +}; +struct _zend_execute_data { + const zend_op *opline; + zend_execute_data *call; + zval *return_value; + zend_function *func; + zval This; + zend_execute_data *prev_execute_data; + zend_array *symbol_table; + void **run_time_cache; + zend_array *extra_named_params; +}; +typedef struct _zend_closure { + zend_object std; + zend_function func; + zval this_ptr; + zend_class_entry *called_scope; + zif_handler orig_internal_handler; +} zend_closure; +extern const zend_object_handlers std_object_handlers; +typedef zval *(*zend_object_read_property_t)(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv); +typedef zval *(*zend_object_read_dimension_t)(zend_object *object, zval *offset, int type, zval *rv); +typedef zval *(*zend_object_write_property_t)(zend_object *object, zend_string *member, zval *value, void **cache_slot); +typedef void (*zend_object_write_dimension_t)(zend_object *object, zval *offset, zval *value); +typedef zval *(*zend_object_get_property_ptr_ptr_t)(zend_object *object, zend_string *member, int type, void **cache_slot); +typedef int (*zend_object_has_property_t)(zend_object *object, zend_string *member, int has_set_exists, void **cache_slot); +typedef int (*zend_object_has_dimension_t)(zend_object *object, zval *member, int check_empty); +typedef void (*zend_object_unset_property_t)(zend_object *object, zend_string *member, void **cache_slot); +typedef void (*zend_object_unset_dimension_t)(zend_object *object, zval *offset); +typedef HashTable *(*zend_object_get_properties_t)(zend_object *object); +typedef HashTable *(*zend_object_get_debug_info_t)(zend_object *object, int *is_temp); +typedef enum _zend_prop_purpose { + ZEND_PROP_PURPOSE_DEBUG, + ZEND_PROP_PURPOSE_ARRAY_CAST, + ZEND_PROP_PURPOSE_SERIALIZE, + ZEND_PROP_PURPOSE_VAR_EXPORT, + ZEND_PROP_PURPOSE_JSON, + _ZEND_PROP_PURPOSE_NON_EXHAUSTIVE_ENUM +} zend_prop_purpose; +typedef zend_array *(*zend_object_get_properties_for_t)(zend_object *object, zend_prop_purpose purpose); +typedef zend_function *(*zend_object_get_method_t)(zend_object **object, zend_string *method, const zval *key); +typedef zend_function *(*zend_object_get_constructor_t)(zend_object *object); +typedef void (*zend_object_dtor_obj_t)(zend_object *object); +typedef void (*zend_object_free_obj_t)(zend_object *object); +typedef zend_object* (*zend_object_clone_obj_t)(zend_object *object); +typedef zend_string *(*zend_object_get_class_name_t)(const zend_object *object); +typedef int (*zend_object_compare_t)(zval *object1, zval *object2); +typedef int (*zend_object_cast_t)(zend_object *readobj, zval *retval, int type); +typedef int (*zend_object_count_elements_t)(zend_object *object, zend_long *count); +typedef int (*zend_object_get_closure_t)(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, zend_bool check_only); +typedef HashTable *(*zend_object_get_gc_t)(zend_object *object, zval **table, int *n); +typedef int (*zend_object_do_operation_t)(zend_uchar opcode, zval *result, zval *op1, zval *op2); +struct _zend_object_handlers { + int offset; + zend_object_free_obj_t free_obj; + zend_object_dtor_obj_t dtor_obj; + zend_object_clone_obj_t clone_obj; + zend_object_read_property_t read_property; + zend_object_write_property_t write_property; + zend_object_read_dimension_t read_dimension; + zend_object_write_dimension_t write_dimension; + zend_object_get_property_ptr_ptr_t get_property_ptr_ptr; + zend_object_has_property_t has_property; + zend_object_unset_property_t unset_property; + zend_object_has_dimension_t has_dimension; + zend_object_unset_dimension_t unset_dimension; + zend_object_get_properties_t get_properties; + zend_object_get_method_t get_method; + zend_object_get_constructor_t get_constructor; + zend_object_get_class_name_t get_class_name; + zend_object_cast_t cast_object; + zend_object_count_elements_t count_elements; + zend_object_get_debug_info_t get_debug_info; + zend_object_get_closure_t get_closure; + zend_object_get_gc_t get_gc; + zend_object_do_operation_t do_operation; + zend_object_compare_t compare; + zend_object_get_properties_for_t get_properties_for; +}; +typedef struct _zend_llist_element { + struct _zend_llist_element *next; + struct _zend_llist_element *prev; + char data[1]; +} zend_llist_element; +typedef void (*llist_dtor_func_t)(void *); +typedef int (*llist_compare_func_t)(const zend_llist_element **, const zend_llist_element **); +typedef void (*llist_apply_with_args_func_t)(void *data, int num_args, va_list args); +typedef void (*llist_apply_with_arg_func_t)(void *data, void *arg); +typedef void (*llist_apply_func_t)(void *); +typedef struct _zend_llist { + zend_llist_element *head; + zend_llist_element *tail; + size_t count; + size_t size; + llist_dtor_func_t dtor; + unsigned char persistent; + zend_llist_element *traverse_ptr; +} zend_llist; +typedef zend_llist_element* zend_llist_position; +typedef struct _zend_encoding zend_encoding; +typedef struct _zend_stack { + int size, top, max; + void *elements; +} zend_stack; +typedef struct _zend_vm_stack *zend_vm_stack; +typedef struct _zend_ini_entry zend_ini_entry; +typedef enum { + ON_TOKEN, + ON_FEEDBACK, + ON_STOP +} zend_php_scanner_event; +struct _zend_vm_stack { + zval *top; + zval *end; + zend_vm_stack prev; +}; +typedef struct _zend_function_entry { + const char *fname; + zif_handler handler; + const struct _zend_internal_arg_info *arg_info; + uint32_t num_args; + uint32_t flags; +} zend_function_entry; +typedef struct _zend_fcall_info { + size_t size; + zval function_name; + zval *retval; + zval *params; + zend_object *object; + uint32_t param_count; + HashTable *named_params; +} zend_fcall_info; +typedef struct _zend_fcall_info_cache { + zend_function *function_handler; + zend_class_entry *calling_scope; + zend_class_entry *called_scope; + zend_object *object; +} zend_fcall_info_cache; +typedef struct _zend_object_iterator zend_object_iterator; +typedef struct _zend_object_iterator_funcs { + void (*dtor)(zend_object_iterator *iter); + int (*valid)(zend_object_iterator *iter); + zval *(*get_current_data)(zend_object_iterator *iter); + void (*get_current_key)(zend_object_iterator *iter, zval *key); + void (*move_forward)(zend_object_iterator *iter); + void (*rewind)(zend_object_iterator *iter); + void (*invalidate_current)(zend_object_iterator *iter); + HashTable *(*get_gc)(zend_object_iterator *iter, zval **table, int *n); +} zend_object_iterator_funcs; +struct _zend_object_iterator { + zend_object std; + zval data; + const zend_object_iterator_funcs *funcs; + zend_ulong index; +}; +typedef struct _zend_class_iterator_funcs { + zend_function *zf_new_iterator; + zend_function *zf_valid; + zend_function *zf_current; + zend_function *zf_key; + zend_function *zf_next; + zend_function *zf_rewind; +} zend_class_iterator_funcs; +struct _zend_serialize_data; +struct _zend_unserialize_data; +typedef struct _zend_serialize_data zend_serialize_data; +typedef struct _zend_unserialize_data zend_unserialize_data; +typedef struct _zend_class_name { + zend_string *name; + zend_string *lc_name; +} zend_class_name; +typedef struct _zend_trait_method_reference { + zend_string *method_name; + zend_string *class_name; +} zend_trait_method_reference; +typedef struct _zend_trait_precedence { + zend_trait_method_reference trait_method; + uint32_t num_excludes; + zend_string *exclude_class_names[1]; +} zend_trait_precedence; +typedef struct _zend_trait_alias { + zend_trait_method_reference trait_method; + zend_string *alias; + uint32_t modifiers; +} zend_trait_alias; +struct _zend_class_entry { + char type; + zend_string *name; + union { + zend_class_entry *parent; + zend_string *parent_name; + }; + int refcount; + uint32_t ce_flags; + int default_properties_count; + int default_static_members_count; + zval *default_properties_table; + zval *default_static_members_table; + zval * * static_members_table__ptr; + HashTable function_table; + HashTable properties_info; + HashTable constants_table; + struct _zend_property_info **properties_info_table; + zend_function *constructor; + zend_function *destructor; + zend_function *clone; + zend_function *__get; + zend_function *__set; + zend_function *__unset; + zend_function *__isset; + zend_function *__call; + zend_function *__callstatic; + zend_function *__tostring; + zend_function *__debugInfo; + zend_function *__serialize; + zend_function *__unserialize; + zend_class_iterator_funcs *iterator_funcs_ptr; + union { + zend_object* (*create_object)(zend_class_entry *class_type); + int (*interface_gets_implemented)(zend_class_entry *iface, zend_class_entry *class_type); + }; + zend_object_iterator *(*get_iterator)(zend_class_entry *ce, zval *object, int by_ref); + zend_function *(*get_static_method)(zend_class_entry *ce, zend_string* method); + int (*serialize)(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data); + int (*unserialize)(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data); + uint32_t num_interfaces; + uint32_t num_traits; + union { + zend_class_entry **interfaces; + zend_class_name *interface_names; + }; + zend_class_name *trait_names; + zend_trait_alias **trait_aliases; + zend_trait_precedence **trait_precedences; + HashTable *attributes; + union { + struct { + zend_string *filename; + uint32_t line_start; + uint32_t line_end; + zend_string *doc_comment; + } user; + struct { + const struct _zend_function_entry *builtin_functions; + struct _zend_module_entry *module; + } internal; + } info; +}; +typedef enum { + EH_NORMAL = 0, + EH_THROW +} zend_error_handling_t; +typedef struct { + zend_error_handling_t handling; + zend_class_entry *exception; +} zend_error_handling; +typedef struct _zend_objects_store { + zend_object **object_buckets; + uint32_t top; + uint32_t size; + int free_list_head; +} zend_objects_store; +struct _zend_ini_entry { + zend_string *name; + int (*on_modify)(zend_ini_entry *entry, zend_string *new_value, void *mh_arg1, void *mh_arg2, void *mh_arg3, int stage); + void *mh_arg1; + void *mh_arg2; + void *mh_arg3; + zend_string *value; + zend_string *orig_value; + void (*displayer)(zend_ini_entry *ini_entry, int type); + int module_number; + uint8_t modifiable; + uint8_t orig_modifiable; + uint8_t modified; +}; +typedef struct _zend_module_entry zend_module_entry; +typedef struct _zend_module_dep zend_module_dep; +typedef ZEND_RESULT_CODE zend_result; +typedef int ts_rsrc_id; +struct _zend_module_entry { + unsigned short size; + unsigned int zend_api; + unsigned char zend_debug; + unsigned char zts; + const struct _zend_ini_entry *ini_entry; + const struct _zend_module_dep *deps; + const char *name; + const struct _zend_function_entry *functions; + zend_result (*module_startup_func)(int type, int module_number); + zend_result (*module_shutdown_func)(int type, int module_number); + zend_result (*request_startup_func)(int type, int module_number); + zend_result (*request_shutdown_func)(int type, int module_number); + void (*info_func)(zend_module_entry *zend_module); + const char *version; + size_t globals_size; + ts_rsrc_id* globals_id_ptr; + void (*globals_ctor)(void *global); + void (*globals_dtor)(void *global); + zend_result (*post_deactivate_func)(void); + int module_started; + unsigned char type; + void *handle; + int module_number; + const char *build_id; +}; +struct _zend_module_dep { + const char *name; + const char *rel; + const char *version; + unsigned char type; +}; +typedef struct _zend_gc_status { + uint32_t runs; + uint32_t collected; + uint32_t threshold; + uint32_t num_roots; +} zend_gc_status; +typedef struct { + zval *cur; + zval *end; + zval *start; +} zend_get_gc_buffer; +struct _zend_compiler_globals { + zend_stack loop_var_stack; + zend_class_entry *active_class_entry; + zend_string *compiled_filename; + int zend_lineno; + zend_op_array *active_op_array; + HashTable *function_table; + HashTable *class_table; + HashTable *auto_globals; + zend_uchar parse_error; + zend_bool in_compilation; + zend_bool short_tags; + zend_bool unclean_shutdown; + zend_bool ini_parser_unbuffered_errors; + zend_llist open_files; + struct _zend_ini_parser_param *ini_parser_param; + zend_bool skip_shebang; + zend_bool increment_lineno; + zend_string *doc_comment; + uint32_t extra_fn_flags; + uint32_t compiler_options; + zend_oparray_context context; + zend_file_context file_context; + zend_arena *arena; + HashTable interned_strings; + const zend_encoding **script_encoding_list; + size_t script_encoding_list_size; + zend_bool multibyte; + zend_bool detect_unicode; + zend_bool encoding_declared; + zend_ast *ast; + zend_arena *ast_arena; + zend_stack delayed_oplines_stack; + HashTable *memoized_exprs; + int memoize_mode; + void *map_ptr_base; + size_t map_ptr_size; + size_t map_ptr_last; + HashTable *delayed_variance_obligations; + HashTable *delayed_autoloads; + uint32_t rtd_key_counter; + zend_stack short_circuiting_opnums; +}; +typedef void jmp_buf; +struct _zend_executor_globals { + zval uninitialized_zval; + zval error_zval; + zend_array *symtable_cache[32]; + zend_array **symtable_cache_limit; + zend_array **symtable_cache_ptr; + zend_array symbol_table; + HashTable included_files; + jmp_buf *bailout; + int error_reporting; + int exit_status; + HashTable *function_table; + HashTable *class_table; + HashTable *zend_constants; + zval *vm_stack_top; + zval *vm_stack_end; + zend_vm_stack vm_stack; + size_t vm_stack_page_size; + struct _zend_execute_data *current_execute_data; + zend_class_entry *fake_scope; + uint32_t jit_trace_num; + zend_long precision; + int ticks_count; + uint32_t persistent_constants_count; + uint32_t persistent_functions_count; + uint32_t persistent_classes_count; + HashTable *in_autoload; + zend_bool full_tables_cleanup; + zend_bool no_extensions; + zend_bool vm_interrupt; + zend_bool timed_out; + zend_long hard_timeout; + HashTable regular_list; + HashTable persistent_list; + int user_error_handler_error_reporting; + zval user_error_handler; + zval user_exception_handler; + zend_stack user_error_handlers_error_reporting; + zend_stack user_error_handlers; + zend_stack user_exception_handlers; + zend_error_handling_t error_handling; + zend_class_entry *exception_class; + zend_long timeout_seconds; + int lambda_count; + HashTable *ini_directives; + HashTable *modified_ini_directives; + zend_ini_entry *error_reporting_ini_entry; + zend_objects_store objects_store; + zend_object *exception, *prev_exception; + const zend_op *opline_before_exception; + zend_op exception_op[3]; + struct _zend_module_entry *current_module; + zend_bool active; + zend_uchar flags; + zend_long assertions; + uint32_t ht_iterators_count; + uint32_t ht_iterators_used; + HashTableIterator *ht_iterators; + HashTableIterator ht_iterators_slots[16]; + void *saved_fpu_cw_ptr; + zend_function trampoline; + zend_op call_trampoline_op; + HashTable weakrefs; + zend_bool exception_ignore_args; + zend_long exception_string_param_max_len; + zend_get_gc_buffer get_gc_buffer; + void *reserved[6]; +}; +typedef struct _zend_executor_globals zend_executor_globals; +typedef struct _IO_FILE FILE; +typedef size_t (*zend_stream_fsizer_t)(void* handle); +typedef ssize_t (*zend_stream_reader_t)(void* handle, char *buf, size_t len); +typedef void (*zend_stream_closer_t)(void* handle); +typedef enum { + ZEND_HANDLE_FILENAME, + ZEND_HANDLE_FP, + ZEND_HANDLE_STREAM +} zend_stream_type; +typedef struct _zend_stream { + void *handle; + int isatty; + zend_stream_reader_t reader; + zend_stream_fsizer_t fsizer; + zend_stream_closer_t closer; +} zend_stream; +typedef struct _zend_file_handle { + union { + FILE *fp; + zend_stream stream; + } handle; + const char *filename; + zend_string *opened_path; + zend_stream_type type; + zend_bool free_filename; + char *buf; + size_t len; +} zend_file_handle; +typedef struct _zend_ptr_stack { + int top, max; + void **elements; + void **top_element; + zend_bool persistent; +} zend_ptr_stack; +typedef size_t (*zend_encoding_filter)(unsigned char **str, size_t *str_length, const unsigned char *buf, size_t length); +typedef struct _zend_lex_state { + unsigned int yy_leng; + unsigned char *yy_start; + unsigned char *yy_text; + unsigned char *yy_cursor; + unsigned char *yy_marker; + unsigned char *yy_limit; + int yy_state; + zend_stack state_stack; + zend_ptr_stack heredoc_label_stack; + zend_stack nest_location_stack; + zend_file_handle *in; + uint32_t lineno; + zend_string *filename; + unsigned char *script_org; + size_t script_org_size; + unsigned char *script_filtered; + size_t script_filtered_size; + zend_encoding_filter input_filter; + zend_encoding_filter output_filter; + const zend_encoding *script_encoding; + void (*on_event)( + zend_php_scanner_event event, int token, int line, + const char *text, size_t length, void *context); + void *on_event_context; + zend_ast *ast; + zend_arena *ast_arena; +} zend_lex_state; +typedef struct _zend_heredoc_label { + char *label; + int length; + int indentation; + zend_bool indentation_uses_spaces; +} zend_heredoc_label; +extern zend_ast_process_t zend_ast_process; +extern HashTable module_registry; +zend_result zend_hash_del(HashTable *ht, zend_string *key); +zval* zend_hash_find(const HashTable *ht, zend_string *key); +zval* zend_hash_add_or_update(HashTable *ht, zend_string *key, zval *pData, uint32_t flag); +int zend_set_user_opcode_handler(zend_uchar opcode, user_opcode_handler_t handler); +user_opcode_handler_t zend_get_user_opcode_handler(zend_uchar opcode); +void zend_do_inheritance_ex(zend_class_entry *ce, zend_class_entry *parent_ce, zend_bool checked); +zend_object* zend_objects_new(zend_class_entry *ce); +void zend_object_std_init(zend_object *object, zend_class_entry *ce); +void object_properties_init(zend_object *object, zend_class_entry *class_type); +void zend_save_lexical_state(zend_lex_state *lex_state); +void zend_restore_lexical_state(zend_lex_state *lex_state); +void zend_prepare_string_for_scanning(zval *str, const char *filename); +zend_result zend_lex_tstring(zval *zv, zend_lexer_ident_ref ident_ref); +int zendparse(void); +void zend_ast_destroy(zend_ast *ast); +zend_ast * zend_ast_create_list_0(zend_ast_kind kind); +zend_ast * zend_ast_list_add(zend_ast *list, zend_ast *op); +zend_ast * zend_ast_create_zval_ex(zval *zv, zend_ast_attr attr); +zend_ast * zend_ast_create_0(zend_ast_kind kind); +zend_ast * zend_ast_create_1(zend_ast_kind kind, zend_ast *child); +zend_ast * zend_ast_create_2(zend_ast_kind kind, zend_ast *child1, zend_ast *child2); +zend_ast * zend_ast_create_3(zend_ast_kind kind, zend_ast *child1, zend_ast *child2, zend_ast *child3); +zend_ast * zend_ast_create_4(zend_ast_kind kind, zend_ast *child1, zend_ast *child2, zend_ast *child3, zend_ast *child4); +zend_ast *zend_ast_create_decl( + zend_ast_kind kind, uint32_t flags, uint32_t start_lineno, zend_string *doc_comment, + zend_string *name, zend_ast *child0, zend_ast *child1, zend_ast *child2, zend_ast *child3, zend_ast *child4 +); +zend_module_entry* zend_register_module_ex(zend_module_entry *module); +zend_result zend_startup_module_ex(zend_module_entry *module); diff --git a/include/engine_8_1_x64_nts.h b/include/engine_8_1_x64_nts.h new file mode 100644 index 0000000..ad05888 --- /dev/null +++ b/include/engine_8_1_x64_nts.h @@ -0,0 +1,942 @@ +#define FFI_SCOPE "ZEngine" +#define FFI_LIB "ZEND_LIBRARY_NAME" +typedef int64_t zend_long; +typedef uint64_t zend_ulong; +typedef int64_t zend_off_t; +typedef _Bool zend_bool; +typedef unsigned char zend_uchar; +typedef struct { + void *ptr; + uint32_t type_mask; +} zend_type; +typedef enum { + SUCCESS = 0, + FAILURE = -1, +} ZEND_RESULT_CODE; +typedef struct _zend_object_handlers zend_object_handlers; +typedef struct _zend_class_entry zend_class_entry; +typedef union _zend_function zend_function; +typedef struct _zend_execute_data zend_execute_data; +typedef struct _zval_struct zval; +typedef struct _zend_refcounted zend_refcounted; +typedef struct _zend_string zend_string; +typedef struct _zend_array zend_array; +typedef struct _zend_object zend_object; +typedef struct _zend_resource zend_resource; +typedef struct _zend_reference zend_reference; +typedef struct _zend_ast_ref zend_ast_ref; +typedef struct _zend_ast zend_ast; +typedef int (*compare_func_t)(const void *, const void *); +typedef void (*swap_func_t)(void *, void *); +typedef void (*sort_func_t)(void *, size_t, size_t, compare_func_t, swap_func_t); +typedef void (*dtor_func_t)(zval *pDest); +typedef void (*copy_ctor_func_t)(zval *pElement); +typedef union _zend_value { + zend_long lval; + double dval; + zend_refcounted *counted; + zend_string *str; + zend_array *arr; + zend_object *obj; + zend_resource *res; + zend_reference *ref; + zend_ast_ref *ast; + zval *zv; + void *ptr; + zend_class_entry *ce; + zend_function *func; + struct { + uint32_t w1; + uint32_t w2; + } ww; +} zend_value; +struct _zval_struct { + zend_value value; + union { + uint32_t type_info; + struct { + zend_uchar type; zend_uchar type_flags; union { uint16_t extra; } u; + } v; + } u1; + union { + uint32_t next; + uint32_t cache_slot; + uint32_t opline_num; + uint32_t lineno; + uint32_t num_args; + uint32_t fe_pos; + uint32_t fe_iter_idx; + uint32_t property_guard; + uint32_t constant_flags; + uint32_t extra; + } u2; +}; +typedef struct _zend_refcounted_h { + uint32_t refcount; + union { + uint32_t type_info; + } u; +} zend_refcounted_h; +struct _zend_refcounted { + zend_refcounted_h gc; +}; +struct _zend_string { + zend_refcounted_h gc; + zend_ulong h; + size_t len; + char val[1]; +}; +typedef struct _Bucket { + zval val; + zend_ulong h; + zend_string *key; +} Bucket; +typedef struct _zend_array HashTable; +struct _zend_array { + zend_refcounted_h gc; + union { + struct { + zend_uchar flags; zend_uchar _unused; zend_uchar nIteratorsCount; zend_uchar _unused2; + } v; + uint32_t flags; + } u; + uint32_t nTableMask; + Bucket *arData; + uint32_t nNumUsed; + uint32_t nNumOfElements; + uint32_t nTableSize; + uint32_t nInternalPointer; + zend_long nNextFreeElement; + dtor_func_t pDestructor; +}; +typedef uint32_t HashPosition; +typedef struct _HashTableIterator { + HashTable *ht; + HashPosition pos; +} HashTableIterator; +struct _zend_object { + zend_refcounted_h gc; + uint32_t handle; + zend_class_entry *ce; + const zend_object_handlers *handlers; + HashTable *properties; + zval properties_table[1]; +}; +struct _zend_resource { + zend_refcounted_h gc; + zend_long handle; + int type; + void *ptr; +}; +typedef struct { + size_t num; + size_t num_allocated; + struct _zend_property_info *ptr[1]; +} zend_property_info_list; +typedef union { + struct _zend_property_info *ptr; + uintptr_t list; +} zend_property_info_source_list; +struct _zend_reference { + zend_refcounted_h gc; + zval val; + zend_property_info_source_list sources; +}; +struct _zend_ast_ref { + zend_refcounted_h gc; +}; +typedef uint16_t zend_ast_kind; +typedef uint16_t zend_ast_attr; +struct _zend_ast { + zend_ast_kind kind; + zend_ast_attr attr; + uint32_t lineno; + zend_ast *child[1]; +}; +typedef struct _zend_ast_list { + zend_ast_kind kind; + zend_ast_attr attr; + uint32_t lineno; + uint32_t children; + zend_ast *child[1]; +} zend_ast_list; +typedef struct _zend_ast_zval { + zend_ast_kind kind; + zend_ast_attr attr; + zval val; +} zend_ast_zval; +typedef struct _zend_ast_decl { + zend_ast_kind kind; + zend_ast_attr attr; + uint32_t start_lineno; + uint32_t end_lineno; + uint32_t flags; + unsigned char *lex_pos; + zend_string *doc_comment; + zend_string *name; + zend_ast *child[5]; +} zend_ast_decl; +typedef void (*zend_ast_process_t)(zend_ast *ast); +typedef intptr_t zend_intptr_t; +typedef uintptr_t zend_uintptr_t; +typedef struct _zend_arena zend_arena; +struct _zend_arena { + char *ptr; + char *end; + zend_arena *prev; +}; +typedef struct _zend_op_array zend_op_array; +typedef struct _zend_op zend_op; +typedef union _znode_op { + uint32_t constant; + uint32_t var; + uint32_t num; + uint32_t opline_num; + uint32_t jmp_offset; +} znode_op; +typedef struct _znode { + zend_uchar op_type; + zend_uchar flag; + union { + znode_op op; + zval constant; + } u; +} znode; +typedef struct _zend_ast_znode { + zend_ast_kind kind; + zend_ast_attr attr; + uint32_t lineno; + znode node; +} zend_ast_znode; +typedef struct _zend_declarables { + zend_long ticks; +} zend_declarables; +typedef struct _zend_file_context { + zend_declarables declarables; + zend_string *current_namespace; + _Bool in_namespace; + _Bool has_bracketed_namespaces; + HashTable *imports; + HashTable *imports_function; + HashTable *imports_const; + HashTable seen_symbols; +} zend_file_context; +typedef union _zend_parser_stack_elem { + zend_ast *ast; + zend_string *str; + zend_ulong num; + unsigned char *ptr; + unsigned char *ident; +} zend_parser_stack_elem; +typedef int (*user_opcode_handler_t) (zend_execute_data *execute_data); +struct _zend_op { + const void *handler; + znode_op op1; + znode_op op2; + znode_op result; + uint32_t extended_value; + uint32_t lineno; + zend_uchar opcode; + zend_uchar op1_type; + zend_uchar op2_type; + zend_uchar result_type; +}; +typedef struct _zend_brk_cont_element { + int start; + int cont; + int brk; + int parent; + _Bool is_switch; +} zend_brk_cont_element; +typedef struct _zend_label { + int brk_cont; + uint32_t opline_num; +} zend_label; +typedef struct _zend_try_catch_element { + uint32_t try_op; + uint32_t catch_op; + uint32_t finally_op; + uint32_t finally_end; +} zend_try_catch_element; +typedef struct _zend_live_range { + uint32_t var; + uint32_t start; + uint32_t end; +} zend_live_range; +typedef struct _zend_oparray_context { + uint32_t opcodes_size; + int vars_size; + int literals_size; + uint32_t fast_call_var; + uint32_t try_catch_offset; + int current_brk_cont; + int last_brk_cont; + zend_brk_cont_element *brk_cont_array; + HashTable *labels; +} zend_oparray_context; +typedef struct _zend_property_info { + uint32_t offset; + uint32_t flags; + zend_string *name; + zend_string *doc_comment; + HashTable *attributes; + zend_class_entry *ce; + zend_type type; +} zend_property_info; +typedef struct _zend_class_constant { + zval value; + zend_string *doc_comment; + HashTable *attributes; + zend_class_entry *ce; +} zend_class_constant; +typedef struct _zend_internal_arg_info { + const char *name; + zend_type type; + const char *default_value; +} zend_internal_arg_info; +typedef struct _zend_arg_info { + zend_string *name; + zend_type type; + zend_string *default_value; +} zend_arg_info; +typedef struct _zend_internal_function_info { + zend_uintptr_t required_num_args; + zend_type type; + const char *default_value; +} zend_internal_function_info; +struct _zend_op_array { + zend_uchar type; + zend_uchar arg_flags[3]; + uint32_t fn_flags; + zend_string *function_name; + zend_class_entry *scope; + zend_function *prototype; + uint32_t num_args; + uint32_t required_num_args; + zend_arg_info *arg_info; + HashTable *attributes; + int cache_size; + int last_var; + uint32_t T; + uint32_t last; + zend_op *opcodes; + void ** * run_time_cache__ptr; + HashTable * * static_variables_ptr__ptr; + HashTable *static_variables; + zend_string **vars; + uint32_t *refcount; + int last_live_range; + int last_try_catch; + zend_live_range *live_range; + zend_try_catch_element *try_catch_array; + zend_string *filename; + uint32_t line_start; + uint32_t line_end; + zend_string *doc_comment; + int last_literal; + uint32_t num_dynamic_func_defs; + zval *literals; + zend_op_array **dynamic_func_defs; + void *reserved[6]; +}; +typedef void ( *zif_handler)(zend_execute_data *execute_data, zval *return_value); +typedef struct _zend_internal_function { + zend_uchar type; + zend_uchar arg_flags[3]; + uint32_t fn_flags; + zend_string* function_name; + zend_class_entry *scope; + zend_function *prototype; + uint32_t num_args; + uint32_t required_num_args; + zend_internal_arg_info *arg_info; + HashTable *attributes; + zif_handler handler; + struct _zend_module_entry *module; + void *reserved[6]; +} zend_internal_function; +union _zend_function { + zend_uchar type; + uint32_t quick_arg_flags; + struct { + zend_uchar type; + zend_uchar arg_flags[3]; + uint32_t fn_flags; + zend_string *function_name; + zend_class_entry *scope; + zend_function *prototype; + uint32_t num_args; + uint32_t required_num_args; + zend_arg_info *arg_info; + HashTable *attributes; + } common; + zend_op_array op_array; + zend_internal_function internal_function; +}; +struct _zend_execute_data { + const zend_op *opline; + zend_execute_data *call; + zval *return_value; + zend_function *func; + zval This; + zend_execute_data *prev_execute_data; + zend_array *symbol_table; + void **run_time_cache; + zend_array *extra_named_params; +}; +typedef struct _zend_closure { + zend_object std; + zend_function func; + zval this_ptr; + zend_class_entry *called_scope; + zif_handler orig_internal_handler; +} zend_closure; +extern const zend_object_handlers std_object_handlers; +typedef zval *(*zend_object_read_property_t)(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv); +typedef zval *(*zend_object_read_dimension_t)(zend_object *object, zval *offset, int type, zval *rv); +typedef zval *(*zend_object_write_property_t)(zend_object *object, zend_string *member, zval *value, void **cache_slot); +typedef void (*zend_object_write_dimension_t)(zend_object *object, zval *offset, zval *value); +typedef zval *(*zend_object_get_property_ptr_ptr_t)(zend_object *object, zend_string *member, int type, void **cache_slot); +typedef int (*zend_object_has_property_t)(zend_object *object, zend_string *member, int has_set_exists, void **cache_slot); +typedef int (*zend_object_has_dimension_t)(zend_object *object, zval *member, int check_empty); +typedef void (*zend_object_unset_property_t)(zend_object *object, zend_string *member, void **cache_slot); +typedef void (*zend_object_unset_dimension_t)(zend_object *object, zval *offset); +typedef HashTable *(*zend_object_get_properties_t)(zend_object *object); +typedef HashTable *(*zend_object_get_debug_info_t)(zend_object *object, int *is_temp); +typedef enum _zend_prop_purpose { + ZEND_PROP_PURPOSE_DEBUG, + ZEND_PROP_PURPOSE_ARRAY_CAST, + ZEND_PROP_PURPOSE_SERIALIZE, + ZEND_PROP_PURPOSE_VAR_EXPORT, + ZEND_PROP_PURPOSE_JSON, + _ZEND_PROP_PURPOSE_NON_EXHAUSTIVE_ENUM +} zend_prop_purpose; +typedef zend_array *(*zend_object_get_properties_for_t)(zend_object *object, zend_prop_purpose purpose); +typedef zend_function *(*zend_object_get_method_t)(zend_object **object, zend_string *method, const zval *key); +typedef zend_function *(*zend_object_get_constructor_t)(zend_object *object); +typedef void (*zend_object_dtor_obj_t)(zend_object *object); +typedef void (*zend_object_free_obj_t)(zend_object *object); +typedef zend_object* (*zend_object_clone_obj_t)(zend_object *object); +typedef zend_string *(*zend_object_get_class_name_t)(const zend_object *object); +typedef int (*zend_object_compare_t)(zval *object1, zval *object2); +typedef int (*zend_object_cast_t)(zend_object *readobj, zval *retval, int type); +typedef int (*zend_object_count_elements_t)(zend_object *object, zend_long *count); +typedef int (*zend_object_get_closure_t)(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, _Bool check_only); +typedef HashTable *(*zend_object_get_gc_t)(zend_object *object, zval **table, int *n); +typedef int (*zend_object_do_operation_t)(zend_uchar opcode, zval *result, zval *op1, zval *op2); +struct _zend_object_handlers { + int offset; + zend_object_free_obj_t free_obj; + zend_object_dtor_obj_t dtor_obj; + zend_object_clone_obj_t clone_obj; + zend_object_read_property_t read_property; + zend_object_write_property_t write_property; + zend_object_read_dimension_t read_dimension; + zend_object_write_dimension_t write_dimension; + zend_object_get_property_ptr_ptr_t get_property_ptr_ptr; + zend_object_has_property_t has_property; + zend_object_unset_property_t unset_property; + zend_object_has_dimension_t has_dimension; + zend_object_unset_dimension_t unset_dimension; + zend_object_get_properties_t get_properties; + zend_object_get_method_t get_method; + zend_object_get_constructor_t get_constructor; + zend_object_get_class_name_t get_class_name; + zend_object_cast_t cast_object; + zend_object_count_elements_t count_elements; + zend_object_get_debug_info_t get_debug_info; + zend_object_get_closure_t get_closure; + zend_object_get_gc_t get_gc; + zend_object_do_operation_t do_operation; + zend_object_compare_t compare; + zend_object_get_properties_for_t get_properties_for; +}; +typedef struct _zend_llist_element { + struct _zend_llist_element *next; + struct _zend_llist_element *prev; + char data[1]; +} zend_llist_element; +typedef void (*llist_dtor_func_t)(void *); +typedef int (*llist_compare_func_t)(const zend_llist_element **, const zend_llist_element **); +typedef void (*llist_apply_with_args_func_t)(void *data, int num_args, va_list args); +typedef void (*llist_apply_with_arg_func_t)(void *data, void *arg); +typedef void (*llist_apply_func_t)(void *); +typedef struct _zend_llist { + zend_llist_element *head; + zend_llist_element *tail; + size_t count; + size_t size; + llist_dtor_func_t dtor; + unsigned char persistent; + zend_llist_element *traverse_ptr; +} zend_llist; +typedef zend_llist_element* zend_llist_position; +typedef struct _zend_encoding zend_encoding; +typedef struct _zend_stack { + int size, top, max; + void *elements; +} zend_stack; +typedef struct _zend_vm_stack *zend_vm_stack; +typedef struct _zend_ini_entry zend_ini_entry; +typedef enum { + ON_TOKEN, + ON_FEEDBACK, + ON_STOP +} zend_php_scanner_event; +struct _zend_vm_stack { + zval *top; + zval *end; + zend_vm_stack prev; +}; +typedef struct _zend_function_entry { + const char *fname; + zif_handler handler; + const struct _zend_internal_arg_info *arg_info; + uint32_t num_args; + uint32_t flags; +} zend_function_entry; +typedef struct _zend_fcall_info { + size_t size; + zval function_name; + zval *retval; + zval *params; + zend_object *object; + uint32_t param_count; + HashTable *named_params; +} zend_fcall_info; +typedef struct _zend_fcall_info_cache { + zend_function *function_handler; + zend_class_entry *calling_scope; + zend_class_entry *called_scope; + zend_object *object; +} zend_fcall_info_cache; +typedef struct _zend_object_iterator zend_object_iterator; +typedef struct _zend_object_iterator_funcs { + void (*dtor)(zend_object_iterator *iter); + int (*valid)(zend_object_iterator *iter); + zval *(*get_current_data)(zend_object_iterator *iter); + void (*get_current_key)(zend_object_iterator *iter, zval *key); + void (*move_forward)(zend_object_iterator *iter); + void (*rewind)(zend_object_iterator *iter); + void (*invalidate_current)(zend_object_iterator *iter); + HashTable *(*get_gc)(zend_object_iterator *iter, zval **table, int *n); +} zend_object_iterator_funcs; +struct _zend_object_iterator { + zend_object std; + zval data; + const zend_object_iterator_funcs *funcs; + zend_ulong index; +}; +typedef struct _zend_class_iterator_funcs { + zend_function *zf_new_iterator; + zend_function *zf_valid; + zend_function *zf_current; + zend_function *zf_key; + zend_function *zf_next; + zend_function *zf_rewind; +} zend_class_iterator_funcs; +struct _zend_serialize_data; +struct _zend_unserialize_data; +typedef struct _zend_serialize_data zend_serialize_data; +typedef struct _zend_unserialize_data zend_unserialize_data; +typedef struct _zend_class_name { + zend_string *name; + zend_string *lc_name; +} zend_class_name; +typedef struct _zend_trait_method_reference { + zend_string *method_name; + zend_string *class_name; +} zend_trait_method_reference; +typedef struct _zend_trait_precedence { + zend_trait_method_reference trait_method; + uint32_t num_excludes; + zend_string *exclude_class_names[1]; +} zend_trait_precedence; +typedef struct _zend_trait_alias { + zend_trait_method_reference trait_method; + zend_string *alias; + uint32_t modifiers; +} zend_trait_alias; +typedef struct _zend_class_mutable_data { + zval *default_properties_table; + HashTable *constants_table; + uint32_t ce_flags; +} zend_class_mutable_data; +typedef struct _zend_inheritance_cache_entry zend_inheritance_cache_entry; +struct _zend_class_entry { + char type; + zend_string *name; + union { + zend_class_entry *parent; + zend_string *parent_name; + }; + int refcount; + uint32_t ce_flags; + int default_properties_count; + int default_static_members_count; + zval *default_properties_table; + zval *default_static_members_table; + zval * * static_members_table__ptr; + HashTable function_table; + HashTable properties_info; + HashTable constants_table; + zend_class_mutable_data* * mutable_data__ptr; + zend_inheritance_cache_entry *inheritance_cache; + struct _zend_property_info **properties_info_table; + zend_function *constructor; + zend_function *destructor; + zend_function *clone; + zend_function *__get; + zend_function *__set; + zend_function *__unset; + zend_function *__isset; + zend_function *__call; + zend_function *__callstatic; + zend_function *__tostring; + zend_function *__debugInfo; + zend_function *__serialize; + zend_function *__unserialize; + zend_class_iterator_funcs *iterator_funcs_ptr; + union { + zend_object* (*create_object)(zend_class_entry *class_type); + int (*interface_gets_implemented)(zend_class_entry *iface, zend_class_entry *class_type); + }; + zend_object_iterator *(*get_iterator)(zend_class_entry *ce, zval *object, int by_ref); + zend_function *(*get_static_method)(zend_class_entry *ce, zend_string* method); + int (*serialize)(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data); + int (*unserialize)(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data); + uint32_t num_interfaces; + uint32_t num_traits; + union { + zend_class_entry **interfaces; + zend_class_name *interface_names; + }; + zend_class_name *trait_names; + zend_trait_alias **trait_aliases; + zend_trait_precedence **trait_precedences; + HashTable *attributes; + uint32_t enum_backing_type; + HashTable *backed_enum_table; + union { + struct { + zend_string *filename; + uint32_t line_start; + uint32_t line_end; + zend_string *doc_comment; + } user; + struct { + const struct _zend_function_entry *builtin_functions; + struct _zend_module_entry *module; + } internal; + } info; +}; +typedef enum { + EH_NORMAL = 0, + EH_THROW +} zend_error_handling_t; +typedef struct { + zend_error_handling_t handling; + zend_class_entry *exception; +} zend_error_handling; +typedef struct _zend_objects_store { + zend_object **object_buckets; + uint32_t top; + uint32_t size; + int free_list_head; +} zend_objects_store; +struct _zend_ini_entry { + zend_string *name; + int (*on_modify)(zend_ini_entry *entry, zend_string *new_value, void *mh_arg1, void *mh_arg2, void *mh_arg3, int stage); + void *mh_arg1; + void *mh_arg2; + void *mh_arg3; + zend_string *value; + zend_string *orig_value; + void (*displayer)(zend_ini_entry *ini_entry, int type); + int module_number; + uint8_t modifiable; + uint8_t orig_modifiable; + uint8_t modified; +}; +typedef struct _zend_module_entry zend_module_entry; +typedef struct _zend_module_dep zend_module_dep; +typedef ZEND_RESULT_CODE zend_result; +struct _zend_module_entry { + unsigned short size; + unsigned int zend_api; + unsigned char zend_debug; + unsigned char zts; + const struct _zend_ini_entry *ini_entry; + const struct _zend_module_dep *deps; + const char *name; + const struct _zend_function_entry *functions; + zend_result (*module_startup_func)(int type, int module_number); + zend_result (*module_shutdown_func)(int type, int module_number); + zend_result (*request_startup_func)(int type, int module_number); + zend_result (*request_shutdown_func)(int type, int module_number); + void (*info_func)(zend_module_entry *zend_module); + const char *version; + size_t globals_size; + void* globals_ptr; + void (*globals_ctor)(void *global); + void (*globals_dtor)(void *global); + zend_result (*post_deactivate_func)(void); + int module_started; + unsigned char type; + void *handle; + int module_number; + const char *build_id; +}; +struct _zend_module_dep { + const char *name; + const char *rel; + const char *version; + unsigned char type; +}; +typedef struct _zend_gc_status { + uint32_t runs; + uint32_t collected; + uint32_t threshold; + uint32_t num_roots; +} zend_gc_status; +typedef struct { + zval *cur; + zval *end; + zval *start; +} zend_get_gc_buffer; +struct _zend_compiler_globals { + zend_stack loop_var_stack; + zend_class_entry *active_class_entry; + zend_string *compiled_filename; + int zend_lineno; + zend_op_array *active_op_array; + HashTable *function_table; + HashTable *class_table; + HashTable *auto_globals; + zend_uchar parse_error; + _Bool in_compilation; + _Bool short_tags; + _Bool unclean_shutdown; + _Bool ini_parser_unbuffered_errors; + zend_llist open_files; + struct _zend_ini_parser_param *ini_parser_param; + _Bool skip_shebang; + _Bool increment_lineno; + _Bool variable_width_locale; + _Bool ascii_compatible_locale; + zend_string *doc_comment; + uint32_t extra_fn_flags; + uint32_t compiler_options; + zend_oparray_context context; + zend_file_context file_context; + zend_arena *arena; + HashTable interned_strings; + const zend_encoding **script_encoding_list; + size_t script_encoding_list_size; + _Bool multibyte; + _Bool detect_unicode; + _Bool encoding_declared; + zend_ast *ast; + zend_arena *ast_arena; + zend_stack delayed_oplines_stack; + HashTable *memoized_exprs; + int memoize_mode; + void *map_ptr_real_base; + void *map_ptr_base; + size_t map_ptr_size; + size_t map_ptr_last; + HashTable *delayed_variance_obligations; + HashTable *delayed_autoloads; + HashTable *unlinked_uses; + zend_class_entry *current_linking_class; + uint32_t rtd_key_counter; + zend_stack short_circuiting_opnums; +}; +typedef void jmp_buf; +typedef struct _zend_fiber zend_fiber; +typedef struct _zend_fiber_context zend_fiber_context; +typedef struct _zend_error_info { + int type; + uint32_t lineno; + zend_string *filename; + zend_string *message; +} zend_error_info; +struct _zend_executor_globals { + zval uninitialized_zval; + zval error_zval; + zend_array *symtable_cache[32]; + zend_array **symtable_cache_limit; + zend_array **symtable_cache_ptr; + zend_array symbol_table; + HashTable included_files; + jmp_buf *bailout; + int error_reporting; + int exit_status; + HashTable *function_table; + HashTable *class_table; + HashTable *zend_constants; + zval *vm_stack_top; + zval *vm_stack_end; + zend_vm_stack vm_stack; + size_t vm_stack_page_size; + struct _zend_execute_data *current_execute_data; + zend_class_entry *fake_scope; + uint32_t jit_trace_num; + zend_long precision; + int ticks_count; + uint32_t persistent_constants_count; + uint32_t persistent_functions_count; + uint32_t persistent_classes_count; + HashTable *in_autoload; + _Bool full_tables_cleanup; + _Bool no_extensions; + _Bool vm_interrupt; + _Bool timed_out; + zend_long hard_timeout; + HashTable regular_list; + HashTable persistent_list; + int user_error_handler_error_reporting; + zval user_error_handler; + zval user_exception_handler; + zend_stack user_error_handlers_error_reporting; + zend_stack user_error_handlers; + zend_stack user_exception_handlers; + zend_error_handling_t error_handling; + zend_class_entry *exception_class; + zend_long timeout_seconds; + int capture_warnings_during_sccp; + HashTable *ini_directives; + HashTable *modified_ini_directives; + zend_ini_entry *error_reporting_ini_entry; + zend_objects_store objects_store; + zend_object *exception, *prev_exception; + const zend_op *opline_before_exception; + zend_op exception_op[3]; + struct _zend_module_entry *current_module; + _Bool active; + zend_uchar flags; + zend_long assertions; + uint32_t ht_iterators_count; + uint32_t ht_iterators_used; + HashTableIterator *ht_iterators; + HashTableIterator ht_iterators_slots[16]; + void *saved_fpu_cw_ptr; + zend_function trampoline; + zend_op call_trampoline_op; + HashTable weakrefs; + _Bool exception_ignore_args; + zend_long exception_string_param_max_len; + zend_get_gc_buffer get_gc_buffer; + zend_fiber_context *main_fiber_context; + zend_fiber_context *current_fiber_context; + zend_fiber *active_fiber; + zend_long fiber_stack_size; + _Bool record_errors; + uint32_t num_errors; + zend_error_info **errors; + void *reserved[6]; +}; +typedef struct _zend_executor_globals zend_executor_globals; +extern zend_executor_globals executor_globals; +extern struct _zend_compiler_globals compiler_globals; +typedef struct _IO_FILE FILE; +typedef size_t (*zend_stream_fsizer_t)(void* handle); +typedef ssize_t (*zend_stream_reader_t)(void* handle, char *buf, size_t len); +typedef void (*zend_stream_closer_t)(void* handle); +typedef enum { + ZEND_HANDLE_FILENAME, + ZEND_HANDLE_FP, + ZEND_HANDLE_STREAM +} zend_stream_type; +typedef struct _zend_stream { + void *handle; + int isatty; + zend_stream_reader_t reader; + zend_stream_fsizer_t fsizer; + zend_stream_closer_t closer; +} zend_stream; +typedef struct _zend_file_handle { + union { + FILE *fp; + zend_stream stream; + } handle; + zend_string *filename; + zend_string *opened_path; + zend_uchar type; + _Bool primary_script; + _Bool in_list; + char *buf; + size_t len; +} zend_file_handle; +typedef struct _zend_ptr_stack { + int top, max; + void **elements; + void **top_element; + _Bool persistent; +} zend_ptr_stack; +typedef size_t (*zend_encoding_filter)(unsigned char **str, size_t *str_length, const unsigned char *buf, size_t length); +typedef struct _zend_lex_state { + unsigned int yy_leng; + unsigned char *yy_start; + unsigned char *yy_text; + unsigned char *yy_cursor; + unsigned char *yy_marker; + unsigned char *yy_limit; + int yy_state; + zend_stack state_stack; + zend_ptr_stack heredoc_label_stack; + zend_stack nest_location_stack; + zend_file_handle *in; + uint32_t lineno; + zend_string *filename; + unsigned char *script_org; + size_t script_org_size; + unsigned char *script_filtered; + size_t script_filtered_size; + zend_encoding_filter input_filter; + zend_encoding_filter output_filter; + const zend_encoding *script_encoding; + void (*on_event)( + zend_php_scanner_event event, int token, int line, + const char *text, size_t length, void *context); + void *on_event_context; + zend_ast *ast; + zend_arena *ast_arena; +} zend_lex_state; +typedef struct _zend_heredoc_label { + char *label; + int length; + int indentation; + _Bool indentation_uses_spaces; +} zend_heredoc_label; +extern zend_ast_process_t zend_ast_process; +extern HashTable module_registry; +zend_result zend_hash_del(HashTable *ht, zend_string *key); +zval* zend_hash_find(const HashTable *ht, zend_string *key); +zval* zend_hash_add_or_update(HashTable *ht, zend_string *key, zval *pData, uint32_t flag); +int zend_set_user_opcode_handler(zend_uchar opcode, user_opcode_handler_t handler); +user_opcode_handler_t zend_get_user_opcode_handler(zend_uchar opcode); +void zend_do_inheritance_ex(zend_class_entry *ce, zend_class_entry *parent_ce, _Bool checked); +zend_object* zend_objects_new(zend_class_entry *ce); +void zend_object_std_init(zend_object *object, zend_class_entry *ce); +void object_properties_init(zend_object *object, zend_class_entry *class_type); +void zend_save_lexical_state(zend_lex_state *lex_state); +void zend_restore_lexical_state(zend_lex_state *lex_state); +void zend_prepare_string_for_scanning(zval *str, zend_string *filename); +zend_result zend_lex_tstring(zval *zv, unsigned char *ident); +int zendparse(void); +void zend_ast_destroy(zend_ast *ast); +zend_ast * zend_ast_create_list_0(zend_ast_kind kind); +zend_ast * zend_ast_list_add(zend_ast *list, zend_ast *op); +zend_ast * zend_ast_create_zval_ex(zval *zv, zend_ast_attr attr); +zend_ast * zend_ast_create_0(zend_ast_kind kind); +zend_ast * zend_ast_create_1(zend_ast_kind kind, zend_ast *child); +zend_ast * zend_ast_create_2(zend_ast_kind kind, zend_ast *child1, zend_ast *child2); +zend_ast * zend_ast_create_3(zend_ast_kind kind, zend_ast *child1, zend_ast *child2, zend_ast *child3); +zend_ast * zend_ast_create_4(zend_ast_kind kind, zend_ast *child1, zend_ast *child2, zend_ast *child3, zend_ast *child4); +zend_ast *zend_ast_create_decl( + zend_ast_kind kind, uint32_t flags, uint32_t start_lineno, zend_string *doc_comment, + zend_string *name, zend_ast *child0, zend_ast *child1, zend_ast *child2, zend_ast *child3, zend_ast *child4 +); +zend_module_entry* zend_register_module_ex(zend_module_entry *module); +zend_result zend_startup_module_ex(zend_module_entry *module); diff --git a/include/engine_8_1_x64_zts.h b/include/engine_8_1_x64_zts.h new file mode 100644 index 0000000..e5d0ed6 --- /dev/null +++ b/include/engine_8_1_x64_zts.h @@ -0,0 +1,941 @@ +#define FFI_SCOPE "ZEngine" +#define FFI_LIB "ZEND_LIBRARY_NAME" +typedef int64_t zend_long; +typedef uint64_t zend_ulong; +typedef int64_t zend_off_t; +typedef _Bool zend_bool; +typedef unsigned char zend_uchar; +typedef struct { + void *ptr; + uint32_t type_mask; +} zend_type; +typedef enum { + SUCCESS = 0, + FAILURE = -1, +} ZEND_RESULT_CODE; +typedef struct _zend_object_handlers zend_object_handlers; +typedef struct _zend_class_entry zend_class_entry; +typedef union _zend_function zend_function; +typedef struct _zend_execute_data zend_execute_data; +typedef struct _zval_struct zval; +typedef struct _zend_refcounted zend_refcounted; +typedef struct _zend_string zend_string; +typedef struct _zend_array zend_array; +typedef struct _zend_object zend_object; +typedef struct _zend_resource zend_resource; +typedef struct _zend_reference zend_reference; +typedef struct _zend_ast_ref zend_ast_ref; +typedef struct _zend_ast zend_ast; +typedef int (*compare_func_t)(const void *, const void *); +typedef void (*swap_func_t)(void *, void *); +typedef void (*sort_func_t)(void *, size_t, size_t, compare_func_t, swap_func_t); +typedef void (*dtor_func_t)(zval *pDest); +typedef void (*copy_ctor_func_t)(zval *pElement); +typedef union _zend_value { + zend_long lval; + double dval; + zend_refcounted *counted; + zend_string *str; + zend_array *arr; + zend_object *obj; + zend_resource *res; + zend_reference *ref; + zend_ast_ref *ast; + zval *zv; + void *ptr; + zend_class_entry *ce; + zend_function *func; + struct { + uint32_t w1; + uint32_t w2; + } ww; +} zend_value; +struct _zval_struct { + zend_value value; + union { + uint32_t type_info; + struct { + zend_uchar type; zend_uchar type_flags; union { uint16_t extra; } u; + } v; + } u1; + union { + uint32_t next; + uint32_t cache_slot; + uint32_t opline_num; + uint32_t lineno; + uint32_t num_args; + uint32_t fe_pos; + uint32_t fe_iter_idx; + uint32_t property_guard; + uint32_t constant_flags; + uint32_t extra; + } u2; +}; +typedef struct _zend_refcounted_h { + uint32_t refcount; + union { + uint32_t type_info; + } u; +} zend_refcounted_h; +struct _zend_refcounted { + zend_refcounted_h gc; +}; +struct _zend_string { + zend_refcounted_h gc; + zend_ulong h; + size_t len; + char val[1]; +}; +typedef struct _Bucket { + zval val; + zend_ulong h; + zend_string *key; +} Bucket; +typedef struct _zend_array HashTable; +struct _zend_array { + zend_refcounted_h gc; + union { + struct { + zend_uchar flags; zend_uchar _unused; zend_uchar nIteratorsCount; zend_uchar _unused2; + } v; + uint32_t flags; + } u; + uint32_t nTableMask; + Bucket *arData; + uint32_t nNumUsed; + uint32_t nNumOfElements; + uint32_t nTableSize; + uint32_t nInternalPointer; + zend_long nNextFreeElement; + dtor_func_t pDestructor; +}; +typedef uint32_t HashPosition; +typedef struct _HashTableIterator { + HashTable *ht; + HashPosition pos; +} HashTableIterator; +struct _zend_object { + zend_refcounted_h gc; + uint32_t handle; + zend_class_entry *ce; + const zend_object_handlers *handlers; + HashTable *properties; + zval properties_table[1]; +}; +struct _zend_resource { + zend_refcounted_h gc; + zend_long handle; + int type; + void *ptr; +}; +typedef struct { + size_t num; + size_t num_allocated; + struct _zend_property_info *ptr[1]; +} zend_property_info_list; +typedef union { + struct _zend_property_info *ptr; + uintptr_t list; +} zend_property_info_source_list; +struct _zend_reference { + zend_refcounted_h gc; + zval val; + zend_property_info_source_list sources; +}; +struct _zend_ast_ref { + zend_refcounted_h gc; +}; +typedef uint16_t zend_ast_kind; +typedef uint16_t zend_ast_attr; +struct _zend_ast { + zend_ast_kind kind; + zend_ast_attr attr; + uint32_t lineno; + zend_ast *child[1]; +}; +typedef struct _zend_ast_list { + zend_ast_kind kind; + zend_ast_attr attr; + uint32_t lineno; + uint32_t children; + zend_ast *child[1]; +} zend_ast_list; +typedef struct _zend_ast_zval { + zend_ast_kind kind; + zend_ast_attr attr; + zval val; +} zend_ast_zval; +typedef struct _zend_ast_decl { + zend_ast_kind kind; + zend_ast_attr attr; + uint32_t start_lineno; + uint32_t end_lineno; + uint32_t flags; + unsigned char *lex_pos; + zend_string *doc_comment; + zend_string *name; + zend_ast *child[5]; +} zend_ast_decl; +typedef void (*zend_ast_process_t)(zend_ast *ast); +typedef intptr_t zend_intptr_t; +typedef uintptr_t zend_uintptr_t; +typedef struct _zend_arena zend_arena; +struct _zend_arena { + char *ptr; + char *end; + zend_arena *prev; +}; +typedef struct _zend_op_array zend_op_array; +typedef struct _zend_op zend_op; +typedef union _znode_op { + uint32_t constant; + uint32_t var; + uint32_t num; + uint32_t opline_num; + uint32_t jmp_offset; +} znode_op; +typedef struct _znode { + zend_uchar op_type; + zend_uchar flag; + union { + znode_op op; + zval constant; + } u; +} znode; +typedef struct _zend_ast_znode { + zend_ast_kind kind; + zend_ast_attr attr; + uint32_t lineno; + znode node; +} zend_ast_znode; +typedef struct _zend_declarables { + zend_long ticks; +} zend_declarables; +typedef struct _zend_file_context { + zend_declarables declarables; + zend_string *current_namespace; + _Bool in_namespace; + _Bool has_bracketed_namespaces; + HashTable *imports; + HashTable *imports_function; + HashTable *imports_const; + HashTable seen_symbols; +} zend_file_context; +typedef union _zend_parser_stack_elem { + zend_ast *ast; + zend_string *str; + zend_ulong num; + unsigned char *ptr; + unsigned char *ident; +} zend_parser_stack_elem; +typedef int (*user_opcode_handler_t) (zend_execute_data *execute_data); +struct _zend_op { + const void *handler; + znode_op op1; + znode_op op2; + znode_op result; + uint32_t extended_value; + uint32_t lineno; + zend_uchar opcode; + zend_uchar op1_type; + zend_uchar op2_type; + zend_uchar result_type; +}; +typedef struct _zend_brk_cont_element { + int start; + int cont; + int brk; + int parent; + _Bool is_switch; +} zend_brk_cont_element; +typedef struct _zend_label { + int brk_cont; + uint32_t opline_num; +} zend_label; +typedef struct _zend_try_catch_element { + uint32_t try_op; + uint32_t catch_op; + uint32_t finally_op; + uint32_t finally_end; +} zend_try_catch_element; +typedef struct _zend_live_range { + uint32_t var; + uint32_t start; + uint32_t end; +} zend_live_range; +typedef struct _zend_oparray_context { + uint32_t opcodes_size; + int vars_size; + int literals_size; + uint32_t fast_call_var; + uint32_t try_catch_offset; + int current_brk_cont; + int last_brk_cont; + zend_brk_cont_element *brk_cont_array; + HashTable *labels; +} zend_oparray_context; +typedef struct _zend_property_info { + uint32_t offset; + uint32_t flags; + zend_string *name; + zend_string *doc_comment; + HashTable *attributes; + zend_class_entry *ce; + zend_type type; +} zend_property_info; +typedef struct _zend_class_constant { + zval value; + zend_string *doc_comment; + HashTable *attributes; + zend_class_entry *ce; +} zend_class_constant; +typedef struct _zend_internal_arg_info { + const char *name; + zend_type type; + const char *default_value; +} zend_internal_arg_info; +typedef struct _zend_arg_info { + zend_string *name; + zend_type type; + zend_string *default_value; +} zend_arg_info; +typedef struct _zend_internal_function_info { + zend_uintptr_t required_num_args; + zend_type type; + const char *default_value; +} zend_internal_function_info; +struct _zend_op_array { + zend_uchar type; + zend_uchar arg_flags[3]; + uint32_t fn_flags; + zend_string *function_name; + zend_class_entry *scope; + zend_function *prototype; + uint32_t num_args; + uint32_t required_num_args; + zend_arg_info *arg_info; + HashTable *attributes; + int cache_size; + int last_var; + uint32_t T; + uint32_t last; + zend_op *opcodes; + void ** * run_time_cache__ptr; + HashTable * * static_variables_ptr__ptr; + HashTable *static_variables; + zend_string **vars; + uint32_t *refcount; + int last_live_range; + int last_try_catch; + zend_live_range *live_range; + zend_try_catch_element *try_catch_array; + zend_string *filename; + uint32_t line_start; + uint32_t line_end; + zend_string *doc_comment; + int last_literal; + uint32_t num_dynamic_func_defs; + zval *literals; + zend_op_array **dynamic_func_defs; + void *reserved[6]; +}; +typedef void ( *zif_handler)(zend_execute_data *execute_data, zval *return_value); +typedef struct _zend_internal_function { + zend_uchar type; + zend_uchar arg_flags[3]; + uint32_t fn_flags; + zend_string* function_name; + zend_class_entry *scope; + zend_function *prototype; + uint32_t num_args; + uint32_t required_num_args; + zend_internal_arg_info *arg_info; + HashTable *attributes; + zif_handler handler; + struct _zend_module_entry *module; + void *reserved[6]; +} zend_internal_function; +union _zend_function { + zend_uchar type; + uint32_t quick_arg_flags; + struct { + zend_uchar type; + zend_uchar arg_flags[3]; + uint32_t fn_flags; + zend_string *function_name; + zend_class_entry *scope; + zend_function *prototype; + uint32_t num_args; + uint32_t required_num_args; + zend_arg_info *arg_info; + HashTable *attributes; + } common; + zend_op_array op_array; + zend_internal_function internal_function; +}; +struct _zend_execute_data { + const zend_op *opline; + zend_execute_data *call; + zval *return_value; + zend_function *func; + zval This; + zend_execute_data *prev_execute_data; + zend_array *symbol_table; + void **run_time_cache; + zend_array *extra_named_params; +}; +typedef struct _zend_closure { + zend_object std; + zend_function func; + zval this_ptr; + zend_class_entry *called_scope; + zif_handler orig_internal_handler; +} zend_closure; +extern const zend_object_handlers std_object_handlers; +typedef zval *(*zend_object_read_property_t)(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv); +typedef zval *(*zend_object_read_dimension_t)(zend_object *object, zval *offset, int type, zval *rv); +typedef zval *(*zend_object_write_property_t)(zend_object *object, zend_string *member, zval *value, void **cache_slot); +typedef void (*zend_object_write_dimension_t)(zend_object *object, zval *offset, zval *value); +typedef zval *(*zend_object_get_property_ptr_ptr_t)(zend_object *object, zend_string *member, int type, void **cache_slot); +typedef int (*zend_object_has_property_t)(zend_object *object, zend_string *member, int has_set_exists, void **cache_slot); +typedef int (*zend_object_has_dimension_t)(zend_object *object, zval *member, int check_empty); +typedef void (*zend_object_unset_property_t)(zend_object *object, zend_string *member, void **cache_slot); +typedef void (*zend_object_unset_dimension_t)(zend_object *object, zval *offset); +typedef HashTable *(*zend_object_get_properties_t)(zend_object *object); +typedef HashTable *(*zend_object_get_debug_info_t)(zend_object *object, int *is_temp); +typedef enum _zend_prop_purpose { + ZEND_PROP_PURPOSE_DEBUG, + ZEND_PROP_PURPOSE_ARRAY_CAST, + ZEND_PROP_PURPOSE_SERIALIZE, + ZEND_PROP_PURPOSE_VAR_EXPORT, + ZEND_PROP_PURPOSE_JSON, + _ZEND_PROP_PURPOSE_NON_EXHAUSTIVE_ENUM +} zend_prop_purpose; +typedef zend_array *(*zend_object_get_properties_for_t)(zend_object *object, zend_prop_purpose purpose); +typedef zend_function *(*zend_object_get_method_t)(zend_object **object, zend_string *method, const zval *key); +typedef zend_function *(*zend_object_get_constructor_t)(zend_object *object); +typedef void (*zend_object_dtor_obj_t)(zend_object *object); +typedef void (*zend_object_free_obj_t)(zend_object *object); +typedef zend_object* (*zend_object_clone_obj_t)(zend_object *object); +typedef zend_string *(*zend_object_get_class_name_t)(const zend_object *object); +typedef int (*zend_object_compare_t)(zval *object1, zval *object2); +typedef int (*zend_object_cast_t)(zend_object *readobj, zval *retval, int type); +typedef int (*zend_object_count_elements_t)(zend_object *object, zend_long *count); +typedef int (*zend_object_get_closure_t)(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, _Bool check_only); +typedef HashTable *(*zend_object_get_gc_t)(zend_object *object, zval **table, int *n); +typedef int (*zend_object_do_operation_t)(zend_uchar opcode, zval *result, zval *op1, zval *op2); +struct _zend_object_handlers { + int offset; + zend_object_free_obj_t free_obj; + zend_object_dtor_obj_t dtor_obj; + zend_object_clone_obj_t clone_obj; + zend_object_read_property_t read_property; + zend_object_write_property_t write_property; + zend_object_read_dimension_t read_dimension; + zend_object_write_dimension_t write_dimension; + zend_object_get_property_ptr_ptr_t get_property_ptr_ptr; + zend_object_has_property_t has_property; + zend_object_unset_property_t unset_property; + zend_object_has_dimension_t has_dimension; + zend_object_unset_dimension_t unset_dimension; + zend_object_get_properties_t get_properties; + zend_object_get_method_t get_method; + zend_object_get_constructor_t get_constructor; + zend_object_get_class_name_t get_class_name; + zend_object_cast_t cast_object; + zend_object_count_elements_t count_elements; + zend_object_get_debug_info_t get_debug_info; + zend_object_get_closure_t get_closure; + zend_object_get_gc_t get_gc; + zend_object_do_operation_t do_operation; + zend_object_compare_t compare; + zend_object_get_properties_for_t get_properties_for; +}; +typedef struct _zend_llist_element { + struct _zend_llist_element *next; + struct _zend_llist_element *prev; + char data[1]; +} zend_llist_element; +typedef void (*llist_dtor_func_t)(void *); +typedef int (*llist_compare_func_t)(const zend_llist_element **, const zend_llist_element **); +typedef void (*llist_apply_with_args_func_t)(void *data, int num_args, va_list args); +typedef void (*llist_apply_with_arg_func_t)(void *data, void *arg); +typedef void (*llist_apply_func_t)(void *); +typedef struct _zend_llist { + zend_llist_element *head; + zend_llist_element *tail; + size_t count; + size_t size; + llist_dtor_func_t dtor; + unsigned char persistent; + zend_llist_element *traverse_ptr; +} zend_llist; +typedef zend_llist_element* zend_llist_position; +typedef struct _zend_encoding zend_encoding; +typedef struct _zend_stack { + int size, top, max; + void *elements; +} zend_stack; +typedef struct _zend_vm_stack *zend_vm_stack; +typedef struct _zend_ini_entry zend_ini_entry; +typedef enum { + ON_TOKEN, + ON_FEEDBACK, + ON_STOP +} zend_php_scanner_event; +struct _zend_vm_stack { + zval *top; + zval *end; + zend_vm_stack prev; +}; +typedef struct _zend_function_entry { + const char *fname; + zif_handler handler; + const struct _zend_internal_arg_info *arg_info; + uint32_t num_args; + uint32_t flags; +} zend_function_entry; +typedef struct _zend_fcall_info { + size_t size; + zval function_name; + zval *retval; + zval *params; + zend_object *object; + uint32_t param_count; + HashTable *named_params; +} zend_fcall_info; +typedef struct _zend_fcall_info_cache { + zend_function *function_handler; + zend_class_entry *calling_scope; + zend_class_entry *called_scope; + zend_object *object; +} zend_fcall_info_cache; +typedef struct _zend_object_iterator zend_object_iterator; +typedef struct _zend_object_iterator_funcs { + void (*dtor)(zend_object_iterator *iter); + int (*valid)(zend_object_iterator *iter); + zval *(*get_current_data)(zend_object_iterator *iter); + void (*get_current_key)(zend_object_iterator *iter, zval *key); + void (*move_forward)(zend_object_iterator *iter); + void (*rewind)(zend_object_iterator *iter); + void (*invalidate_current)(zend_object_iterator *iter); + HashTable *(*get_gc)(zend_object_iterator *iter, zval **table, int *n); +} zend_object_iterator_funcs; +struct _zend_object_iterator { + zend_object std; + zval data; + const zend_object_iterator_funcs *funcs; + zend_ulong index; +}; +typedef struct _zend_class_iterator_funcs { + zend_function *zf_new_iterator; + zend_function *zf_valid; + zend_function *zf_current; + zend_function *zf_key; + zend_function *zf_next; + zend_function *zf_rewind; +} zend_class_iterator_funcs; +struct _zend_serialize_data; +struct _zend_unserialize_data; +typedef struct _zend_serialize_data zend_serialize_data; +typedef struct _zend_unserialize_data zend_unserialize_data; +typedef struct _zend_class_name { + zend_string *name; + zend_string *lc_name; +} zend_class_name; +typedef struct _zend_trait_method_reference { + zend_string *method_name; + zend_string *class_name; +} zend_trait_method_reference; +typedef struct _zend_trait_precedence { + zend_trait_method_reference trait_method; + uint32_t num_excludes; + zend_string *exclude_class_names[1]; +} zend_trait_precedence; +typedef struct _zend_trait_alias { + zend_trait_method_reference trait_method; + zend_string *alias; + uint32_t modifiers; +} zend_trait_alias; +typedef struct _zend_class_mutable_data { + zval *default_properties_table; + HashTable *constants_table; + uint32_t ce_flags; +} zend_class_mutable_data; +typedef struct _zend_inheritance_cache_entry zend_inheritance_cache_entry; +struct _zend_class_entry { + char type; + zend_string *name; + union { + zend_class_entry *parent; + zend_string *parent_name; + }; + int refcount; + uint32_t ce_flags; + int default_properties_count; + int default_static_members_count; + zval *default_properties_table; + zval *default_static_members_table; + zval * * static_members_table__ptr; + HashTable function_table; + HashTable properties_info; + HashTable constants_table; + zend_class_mutable_data* * mutable_data__ptr; + zend_inheritance_cache_entry *inheritance_cache; + struct _zend_property_info **properties_info_table; + zend_function *constructor; + zend_function *destructor; + zend_function *clone; + zend_function *__get; + zend_function *__set; + zend_function *__unset; + zend_function *__isset; + zend_function *__call; + zend_function *__callstatic; + zend_function *__tostring; + zend_function *__debugInfo; + zend_function *__serialize; + zend_function *__unserialize; + zend_class_iterator_funcs *iterator_funcs_ptr; + union { + zend_object* (*create_object)(zend_class_entry *class_type); + int (*interface_gets_implemented)(zend_class_entry *iface, zend_class_entry *class_type); + }; + zend_object_iterator *(*get_iterator)(zend_class_entry *ce, zval *object, int by_ref); + zend_function *(*get_static_method)(zend_class_entry *ce, zend_string* method); + int (*serialize)(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data); + int (*unserialize)(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data); + uint32_t num_interfaces; + uint32_t num_traits; + union { + zend_class_entry **interfaces; + zend_class_name *interface_names; + }; + zend_class_name *trait_names; + zend_trait_alias **trait_aliases; + zend_trait_precedence **trait_precedences; + HashTable *attributes; + uint32_t enum_backing_type; + HashTable *backed_enum_table; + union { + struct { + zend_string *filename; + uint32_t line_start; + uint32_t line_end; + zend_string *doc_comment; + } user; + struct { + const struct _zend_function_entry *builtin_functions; + struct _zend_module_entry *module; + } internal; + } info; +}; +typedef enum { + EH_NORMAL = 0, + EH_THROW +} zend_error_handling_t; +typedef struct { + zend_error_handling_t handling; + zend_class_entry *exception; +} zend_error_handling; +typedef struct _zend_objects_store { + zend_object **object_buckets; + uint32_t top; + uint32_t size; + int free_list_head; +} zend_objects_store; +struct _zend_ini_entry { + zend_string *name; + int (*on_modify)(zend_ini_entry *entry, zend_string *new_value, void *mh_arg1, void *mh_arg2, void *mh_arg3, int stage); + void *mh_arg1; + void *mh_arg2; + void *mh_arg3; + zend_string *value; + zend_string *orig_value; + void (*displayer)(zend_ini_entry *ini_entry, int type); + int module_number; + uint8_t modifiable; + uint8_t orig_modifiable; + uint8_t modified; +}; +typedef struct _zend_module_entry zend_module_entry; +typedef struct _zend_module_dep zend_module_dep; +typedef ZEND_RESULT_CODE zend_result; +typedef int ts_rsrc_id; +struct _zend_module_entry { + unsigned short size; + unsigned int zend_api; + unsigned char zend_debug; + unsigned char zts; + const struct _zend_ini_entry *ini_entry; + const struct _zend_module_dep *deps; + const char *name; + const struct _zend_function_entry *functions; + zend_result (*module_startup_func)(int type, int module_number); + zend_result (*module_shutdown_func)(int type, int module_number); + zend_result (*request_startup_func)(int type, int module_number); + zend_result (*request_shutdown_func)(int type, int module_number); + void (*info_func)(zend_module_entry *zend_module); + const char *version; + size_t globals_size; + ts_rsrc_id* globals_id_ptr; + void (*globals_ctor)(void *global); + void (*globals_dtor)(void *global); + zend_result (*post_deactivate_func)(void); + int module_started; + unsigned char type; + void *handle; + int module_number; + const char *build_id; +}; +struct _zend_module_dep { + const char *name; + const char *rel; + const char *version; + unsigned char type; +}; +typedef struct _zend_gc_status { + uint32_t runs; + uint32_t collected; + uint32_t threshold; + uint32_t num_roots; +} zend_gc_status; +typedef struct { + zval *cur; + zval *end; + zval *start; +} zend_get_gc_buffer; +struct _zend_compiler_globals { + zend_stack loop_var_stack; + zend_class_entry *active_class_entry; + zend_string *compiled_filename; + int zend_lineno; + zend_op_array *active_op_array; + HashTable *function_table; + HashTable *class_table; + HashTable *auto_globals; + zend_uchar parse_error; + _Bool in_compilation; + _Bool short_tags; + _Bool unclean_shutdown; + _Bool ini_parser_unbuffered_errors; + zend_llist open_files; + struct _zend_ini_parser_param *ini_parser_param; + _Bool skip_shebang; + _Bool increment_lineno; + _Bool variable_width_locale; + _Bool ascii_compatible_locale; + zend_string *doc_comment; + uint32_t extra_fn_flags; + uint32_t compiler_options; + zend_oparray_context context; + zend_file_context file_context; + zend_arena *arena; + HashTable interned_strings; + const zend_encoding **script_encoding_list; + size_t script_encoding_list_size; + _Bool multibyte; + _Bool detect_unicode; + _Bool encoding_declared; + zend_ast *ast; + zend_arena *ast_arena; + zend_stack delayed_oplines_stack; + HashTable *memoized_exprs; + int memoize_mode; + void *map_ptr_real_base; + void *map_ptr_base; + size_t map_ptr_size; + size_t map_ptr_last; + HashTable *delayed_variance_obligations; + HashTable *delayed_autoloads; + HashTable *unlinked_uses; + zend_class_entry *current_linking_class; + uint32_t rtd_key_counter; + zend_stack short_circuiting_opnums; +}; +typedef void jmp_buf; +typedef struct _zend_fiber zend_fiber; +typedef struct _zend_fiber_context zend_fiber_context; +typedef struct _zend_error_info { + int type; + uint32_t lineno; + zend_string *filename; + zend_string *message; +} zend_error_info; +struct _zend_executor_globals { + zval uninitialized_zval; + zval error_zval; + zend_array *symtable_cache[32]; + zend_array **symtable_cache_limit; + zend_array **symtable_cache_ptr; + zend_array symbol_table; + HashTable included_files; + jmp_buf *bailout; + int error_reporting; + int exit_status; + HashTable *function_table; + HashTable *class_table; + HashTable *zend_constants; + zval *vm_stack_top; + zval *vm_stack_end; + zend_vm_stack vm_stack; + size_t vm_stack_page_size; + struct _zend_execute_data *current_execute_data; + zend_class_entry *fake_scope; + uint32_t jit_trace_num; + zend_long precision; + int ticks_count; + uint32_t persistent_constants_count; + uint32_t persistent_functions_count; + uint32_t persistent_classes_count; + HashTable *in_autoload; + _Bool full_tables_cleanup; + _Bool no_extensions; + _Bool vm_interrupt; + _Bool timed_out; + zend_long hard_timeout; + HashTable regular_list; + HashTable persistent_list; + int user_error_handler_error_reporting; + zval user_error_handler; + zval user_exception_handler; + zend_stack user_error_handlers_error_reporting; + zend_stack user_error_handlers; + zend_stack user_exception_handlers; + zend_error_handling_t error_handling; + zend_class_entry *exception_class; + zend_long timeout_seconds; + int capture_warnings_during_sccp; + HashTable *ini_directives; + HashTable *modified_ini_directives; + zend_ini_entry *error_reporting_ini_entry; + zend_objects_store objects_store; + zend_object *exception, *prev_exception; + const zend_op *opline_before_exception; + zend_op exception_op[3]; + struct _zend_module_entry *current_module; + _Bool active; + zend_uchar flags; + zend_long assertions; + uint32_t ht_iterators_count; + uint32_t ht_iterators_used; + HashTableIterator *ht_iterators; + HashTableIterator ht_iterators_slots[16]; + void *saved_fpu_cw_ptr; + zend_function trampoline; + zend_op call_trampoline_op; + HashTable weakrefs; + _Bool exception_ignore_args; + zend_long exception_string_param_max_len; + zend_get_gc_buffer get_gc_buffer; + zend_fiber_context *main_fiber_context; + zend_fiber_context *current_fiber_context; + zend_fiber *active_fiber; + zend_long fiber_stack_size; + _Bool record_errors; + uint32_t num_errors; + zend_error_info **errors; + void *reserved[6]; +}; +typedef struct _zend_executor_globals zend_executor_globals; +typedef struct _IO_FILE FILE; +typedef size_t (*zend_stream_fsizer_t)(void* handle); +typedef ssize_t (*zend_stream_reader_t)(void* handle, char *buf, size_t len); +typedef void (*zend_stream_closer_t)(void* handle); +typedef enum { + ZEND_HANDLE_FILENAME, + ZEND_HANDLE_FP, + ZEND_HANDLE_STREAM +} zend_stream_type; +typedef struct _zend_stream { + void *handle; + int isatty; + zend_stream_reader_t reader; + zend_stream_fsizer_t fsizer; + zend_stream_closer_t closer; +} zend_stream; +typedef struct _zend_file_handle { + union { + FILE *fp; + zend_stream stream; + } handle; + zend_string *filename; + zend_string *opened_path; + zend_uchar type; + _Bool primary_script; + _Bool in_list; + char *buf; + size_t len; +} zend_file_handle; +typedef struct _zend_ptr_stack { + int top, max; + void **elements; + void **top_element; + _Bool persistent; +} zend_ptr_stack; +typedef size_t (*zend_encoding_filter)(unsigned char **str, size_t *str_length, const unsigned char *buf, size_t length); +typedef struct _zend_lex_state { + unsigned int yy_leng; + unsigned char *yy_start; + unsigned char *yy_text; + unsigned char *yy_cursor; + unsigned char *yy_marker; + unsigned char *yy_limit; + int yy_state; + zend_stack state_stack; + zend_ptr_stack heredoc_label_stack; + zend_stack nest_location_stack; + zend_file_handle *in; + uint32_t lineno; + zend_string *filename; + unsigned char *script_org; + size_t script_org_size; + unsigned char *script_filtered; + size_t script_filtered_size; + zend_encoding_filter input_filter; + zend_encoding_filter output_filter; + const zend_encoding *script_encoding; + void (*on_event)( + zend_php_scanner_event event, int token, int line, + const char *text, size_t length, void *context); + void *on_event_context; + zend_ast *ast; + zend_arena *ast_arena; +} zend_lex_state; +typedef struct _zend_heredoc_label { + char *label; + int length; + int indentation; + _Bool indentation_uses_spaces; +} zend_heredoc_label; +extern zend_ast_process_t zend_ast_process; +extern HashTable module_registry; +zend_result zend_hash_del(HashTable *ht, zend_string *key); +zval* zend_hash_find(const HashTable *ht, zend_string *key); +zval* zend_hash_add_or_update(HashTable *ht, zend_string *key, zval *pData, uint32_t flag); +int zend_set_user_opcode_handler(zend_uchar opcode, user_opcode_handler_t handler); +user_opcode_handler_t zend_get_user_opcode_handler(zend_uchar opcode); +void zend_do_inheritance_ex(zend_class_entry *ce, zend_class_entry *parent_ce, _Bool checked); +zend_object* zend_objects_new(zend_class_entry *ce); +void zend_object_std_init(zend_object *object, zend_class_entry *ce); +void object_properties_init(zend_object *object, zend_class_entry *class_type); +void zend_save_lexical_state(zend_lex_state *lex_state); +void zend_restore_lexical_state(zend_lex_state *lex_state); +void zend_prepare_string_for_scanning(zval *str, zend_string *filename); +zend_result zend_lex_tstring(zval *zv, unsigned char *ident); +int zendparse(void); +void zend_ast_destroy(zend_ast *ast); +zend_ast * zend_ast_create_list_0(zend_ast_kind kind); +zend_ast * zend_ast_list_add(zend_ast *list, zend_ast *op); +zend_ast * zend_ast_create_zval_ex(zval *zv, zend_ast_attr attr); +zend_ast * zend_ast_create_0(zend_ast_kind kind); +zend_ast * zend_ast_create_1(zend_ast_kind kind, zend_ast *child); +zend_ast * zend_ast_create_2(zend_ast_kind kind, zend_ast *child1, zend_ast *child2); +zend_ast * zend_ast_create_3(zend_ast_kind kind, zend_ast *child1, zend_ast *child2, zend_ast *child3); +zend_ast * zend_ast_create_4(zend_ast_kind kind, zend_ast *child1, zend_ast *child2, zend_ast *child3, zend_ast *child4); +zend_ast *zend_ast_create_decl( + zend_ast_kind kind, uint32_t flags, uint32_t start_lineno, zend_string *doc_comment, + zend_string *name, zend_ast *child0, zend_ast *child1, zend_ast *child2, zend_ast *child3, zend_ast *child4 +); +zend_module_entry* zend_register_module_ex(zend_module_entry *module); +zend_result zend_startup_module_ex(zend_module_entry *module); diff --git a/include/engine_x64_nts.h b/include/engine_x64_nts.h deleted file mode 100644 index 8bbdf61..0000000 --- a/include/engine_x64_nts.h +++ /dev/null @@ -1,1323 +0,0 @@ -#define FFI_SCOPE "ZEngine" -#define FFI_LIB "ZEND_LIBRARY_NAME" - -typedef int64_t zend_long; -typedef uint64_t zend_ulong; -typedef int64_t zend_off_t; - -typedef unsigned char zend_bool; -typedef unsigned char zend_uchar; -typedef uintptr_t zend_type; - -typedef enum { - SUCCESS = 0, - FAILURE = -1, /* this MUST stay a negative number, or it may affect functions! */ -} ZEND_RESULT_CODE; - -typedef struct _zend_object_handlers zend_object_handlers; -typedef struct _zend_class_entry zend_class_entry; -typedef union _zend_function zend_function; -typedef struct _zend_execute_data zend_execute_data; - -typedef struct _zval_struct zval; - -typedef struct _zend_refcounted zend_refcounted; -typedef struct _zend_string zend_string; -typedef struct _zend_array zend_array; -typedef struct _zend_object zend_object; -typedef struct _zend_resource zend_resource; -typedef struct _zend_reference zend_reference; -typedef struct _zend_ast_ref zend_ast_ref; -typedef struct _zend_ast zend_ast; - -typedef int (*compare_func_t)(const void *, const void *); -typedef void (*swap_func_t)(void *, void *); -typedef void (*sort_func_t)(void *, size_t, size_t, compare_func_t, swap_func_t); -typedef void (*dtor_func_t)(zval *pDest); -typedef void (*copy_ctor_func_t)(zval *pElement); - -typedef union _zend_value { - zend_long lval; /* long value */ - double dval; /* double value */ - zend_refcounted *counted; - zend_string *str; - zend_array *arr; - zend_object *obj; - zend_resource *res; - zend_reference *ref; - zend_ast_ref *ast; - zval *zv; - void *ptr; - zend_class_entry *ce; - zend_function *func; - struct { - uint32_t w1; - uint32_t w2; - } ww; -} zend_value; - -struct _zval_struct { - zend_value value; /* value */ - union { - struct { - zend_uchar type; /* active type */ - zend_uchar type_flags; - union { - uint16_t extra; /* not further specified */ - } u; - } v; - uint32_t type_info; - } u1; - union { - uint32_t next; /* hash collision chain */ - uint32_t cache_slot; /* cache slot (for RECV_INIT) */ - uint32_t opline_num; /* opline number (for FAST_CALL) */ - uint32_t lineno; /* line number (for ast nodes) */ - uint32_t num_args; /* arguments number for EX(This) */ - uint32_t fe_pos; /* foreach position */ - uint32_t fe_iter_idx; /* foreach iterator index */ - uint32_t access_flags; /* class constant access flags */ - uint32_t property_guard; /* single property guard */ - uint32_t constant_flags; /* constant flags */ - uint32_t extra; /* not further specified */ - } u2; -}; - -typedef struct _zend_refcounted_h { - uint32_t refcount; /* reference counter 32-bit */ - union { - uint32_t type_info; - } u; -} zend_refcounted_h; - -struct _zend_refcounted { - zend_refcounted_h gc; -}; - -struct _zend_string { - zend_refcounted_h gc; - zend_ulong h; /* hash value */ - size_t len; - char val[1]; -}; - -typedef struct _Bucket { - zval val; - zend_ulong h; /* hash value (or numeric index) */ - zend_string *key; /* string key or NULL for numerics */ -} Bucket; - -typedef struct _zend_array HashTable; - -struct _zend_array { - zend_refcounted_h gc; - union { - struct { - zend_uchar flags; - zend_uchar _unused; - zend_uchar nIteratorsCount; - zend_uchar _unused2; - } v; - uint32_t flags; - } u; - uint32_t nTableMask; - Bucket *arData; - uint32_t nNumUsed; - uint32_t nNumOfElements; - uint32_t nTableSize; - uint32_t nInternalPointer; - zend_long nNextFreeElement; - dtor_func_t pDestructor; -}; - -typedef uint32_t HashPosition; - -typedef struct _HashTableIterator { - HashTable *ht; - HashPosition pos; -} HashTableIterator; - -struct _zend_object { - zend_refcounted_h gc; - uint32_t handle; // TODO: may be removed ??? - zend_class_entry *ce; - const zend_object_handlers *handlers; - HashTable *properties; - zval properties_table[1]; -}; - -struct _zend_resource { - zend_refcounted_h gc; - int handle; // TODO: may be removed ??? - int type; - void *ptr; -}; - -typedef struct _zend_property_info zend_property_info; - -typedef struct { - size_t num; - size_t num_allocated; - zend_property_info *ptr[1]; -} zend_property_info_list; - -typedef union { - zend_property_info *ptr; - uintptr_t list; -} zend_property_info_source_list; - -struct _zend_reference { - zend_refcounted_h gc; - zval val; - zend_property_info_source_list sources; -}; - -struct _zend_ast_ref { - zend_refcounted_h gc; - /*zend_ast ast; zend_ast follows the zend_ast_ref structure */ -}; - -/* zend_ast.h */ -typedef uint16_t zend_ast_kind; -typedef uint16_t zend_ast_attr; - -struct _zend_ast { - zend_ast_kind kind; /* Type of the node (ZEND_AST_* enum constant) */ - zend_ast_attr attr; /* Additional attribute, use depending on node type */ - uint32_t lineno; /* Line number */ - zend_ast *child[1]; /* Array of children (using struct hack) */ -}; - -/* Same as zend_ast, but with children count, which is updated dynamically */ -typedef struct _zend_ast_list { - zend_ast_kind kind; - zend_ast_attr attr; - uint32_t lineno; - uint32_t children; - zend_ast *child[1]; -} zend_ast_list; - -/* Lineno is stored in val.u2.lineno */ -typedef struct _zend_ast_zval { - zend_ast_kind kind; - zend_ast_attr attr; - zval val; -} zend_ast_zval; - -/* Separate structure for function and class declaration, as they need extra information. */ -typedef struct _zend_ast_decl { - zend_ast_kind kind; - zend_ast_attr attr; /* Unused - for structure compatibility */ - uint32_t start_lineno; - uint32_t end_lineno; - uint32_t flags; - unsigned char *lex_pos; - zend_string *doc_comment; - zend_string *name; - zend_ast *child[4]; -} zend_ast_decl; - -typedef void (*zend_ast_process_t)(zend_ast *ast); - -/* zend_types.h */ -typedef intptr_t zend_intptr_t; -typedef uintptr_t zend_uintptr_t; - -/* zend_arena.h */ -typedef struct _zend_arena zend_arena; - -struct _zend_arena { - char *ptr; - char *end; - zend_arena *prev; -}; - -/* zend_compile.h */ -typedef struct _zend_op_array zend_op_array; -typedef struct _zend_op zend_op; - -typedef union _znode_op { - uint32_t constant; - uint32_t var; - uint32_t num; - uint32_t opline_num; /* Needs to be signed */ - - // We haven't support for #if..#endif constructions, so this resolved by hand - // #if ZEND_USE_ABS_JMP_ADDR - // zend_op *jmp_addr; - // #else - uint32_t jmp_offset; - // #endif - // #if ZEND_USE_ABS_CONST_ADDR - // zval *zv; - // #endif -} znode_op; - -typedef struct _znode { /* used only during compilation */ - zend_uchar op_type; - zend_uchar flag; - union { - znode_op op; - zval constant; /* replaced by literal/zv */ - } u; -} znode; - -typedef struct _zend_ast_znode { - zend_ast_kind kind; - zend_ast_attr attr; - uint32_t lineno; - znode node; -} zend_ast_znode; - -typedef struct _zend_declarables { - zend_long ticks; -} zend_declarables; - -typedef struct _zend_file_context { - zend_declarables declarables; - - zend_string *current_namespace; - zend_bool in_namespace; - zend_bool has_bracketed_namespaces; - - HashTable *imports; - HashTable *imports_function; - HashTable *imports_const; - - HashTable seen_symbols; -} zend_file_context; - -typedef union _zend_parser_stack_elem { - zend_ast *ast; - zend_string *str; - zend_ulong num; - unsigned char *ptr; -} zend_parser_stack_elem; - -typedef int (*user_opcode_handler_t) (zend_execute_data *execute_data); - -struct _zend_op { - const void *handler; - znode_op op1; - znode_op op2; - znode_op result; - uint32_t extended_value; - uint32_t lineno; - zend_uchar opcode; - zend_uchar op1_type; - zend_uchar op2_type; - zend_uchar result_type; -}; - -typedef struct _zend_brk_cont_element { - int start; - int cont; - int brk; - int parent; - zend_bool is_switch; -} zend_brk_cont_element; - -typedef struct _zend_label { - int brk_cont; - uint32_t opline_num; -} zend_label; - -typedef struct _zend_try_catch_element { - uint32_t try_op; - uint32_t catch_op; /* ketchup! */ - uint32_t finally_op; - uint32_t finally_end; -} zend_try_catch_element; - -typedef struct _zend_live_range { - uint32_t var; /* low bits are used for variable type (ZEND_LIVE_* macros) */ - uint32_t start; - uint32_t end; -} zend_live_range; - -typedef struct _zend_oparray_context { - uint32_t opcodes_size; - int vars_size; - int literals_size; - uint32_t fast_call_var; - uint32_t try_catch_offset; - int current_brk_cont; - int last_brk_cont; - zend_brk_cont_element *brk_cont_array; - HashTable *labels; -} zend_oparray_context; - -typedef struct _zend_property_info { - uint32_t offset; /* property offset for object properties or - property index for static properties */ - uint32_t flags; - zend_string *name; - zend_string *doc_comment; - zend_class_entry *ce; - zend_type type; -} zend_property_info; - -typedef struct _zend_class_constant { - zval value; /* access flags are stored in reserved: zval.u2.access_flags */ - zend_string *doc_comment; - HashTable *attributes; - zend_class_entry *ce; -} zend_class_constant; - -/* arg_info for internal functions */ -typedef struct _zend_internal_arg_info { - const char *name; - zend_type type; - zend_uchar pass_by_reference; - zend_bool is_variadic; -} zend_internal_arg_info; - -/* arg_info for user functions */ -typedef struct _zend_arg_info { - zend_string *name; - zend_type type; - zend_uchar pass_by_reference; - zend_bool is_variadic; -} zend_arg_info; - -typedef struct _zend_internal_function_info { - zend_uintptr_t required_num_args; - zend_type type; - zend_bool return_reference; - zend_bool _is_variadic; -} zend_internal_function_info; - -struct _zend_op_array { - /* Common elements */ - zend_uchar type; - zend_uchar arg_flags[3]; /* bitset of arg_info.pass_by_reference */ - uint32_t fn_flags; - zend_string *function_name; - zend_class_entry *scope; - zend_function *prototype; - uint32_t num_args; - uint32_t required_num_args; - zend_arg_info *arg_info; - HashTable *attributes; - /* END of common elements */ - - int cache_size; /* number of run_time_cache_slots * sizeof(void*) */ - int last_var; /* number of CV variables */ - uint32_t T; /* number of temporary variables */ - uint32_t last; /* number of opcodes */ - - zend_op *opcodes; - void ** * run_time_cache; ## __run_time_cache - HashTable * * static_variables_ptr; ## __static_variables_ptr - HashTable *static_variables; - zend_string **vars; /* names of CV variables */ - - uint32_t *refcount; - - int last_live_range; - int last_try_catch; - zend_live_range *live_range; - zend_try_catch_element *try_catch_array; - - zend_string *filename; - uint32_t line_start; - uint32_t line_end; - zend_string *doc_comment; - - int last_literal; - zval *literals; - - void *reserved[ZEND_MAX_RESERVED_RESOURCES]; -}; - -/* zend_internal_function_handler */ -typedef void (*zif_handler)(INTERNAL_FUNCTION_PARAMETERS); - -typedef struct _zend_internal_function { - /* Common elements */ - zend_uchar type; - zend_uchar arg_flags[3]; /* bitset of arg_info.pass_by_reference */ - uint32_t fn_flags; - zend_string* function_name; - zend_class_entry *scope; - zend_function *prototype; - uint32_t num_args; - uint32_t required_num_args; - zend_internal_arg_info *arg_info; - HashTable *attributes; - /* END of common elements */ - - zif_handler handler; - struct _zend_module_entry *module; - void *reserved[ZEND_MAX_RESERVED_RESOURCES]; -} zend_internal_function; - -union _zend_function { - zend_uchar type; /* MUST be the first element of this struct! */ - uint32_t quick_arg_flags; - - struct { - zend_uchar type; /* never used */ - zend_uchar arg_flags[3]; /* bitset of arg_info.pass_by_reference */ - uint32_t fn_flags; - zend_string *function_name; - zend_class_entry *scope; - zend_function *prototype; - uint32_t num_args; - uint32_t required_num_args; - zend_arg_info *arg_info; - HashTable *attributes; - } common; - - zend_op_array op_array; - zend_internal_function internal_function; -}; - -typedef struct _zend_execute_data { - const zend_op *opline; /* executed opline */ - zend_execute_data *call; /* current call */ - zval *return_value; - zend_function *func; /* executed function */ - zval This; /* this + call_info + num_args */ - zend_execute_data *prev_execute_data; - zend_array *symbol_table; - void **run_time_cache; /* cache op_array->run_time_cache */ - zend_array *extra_named_params; -}; - -/* zend_closurec.c */ -typedef struct _zend_closure { - zend_object std; - zend_function func; - zval this_ptr; - zend_class_entry *called_scope; - zif_handler orig_internal_handler; -} zend_closure; - -/* zend_object_handlers.h */ - -extern const ZEND_API zend_object_handlers std_object_handlers; - -/* The following rule applies to read_property() and read_dimension() implementations: - If you return a zval which is not otherwise referenced by the extension or the engine's - symbol table, its reference count should be 0. -*/ -/* Used to fetch property from the object, read-only */ -typedef zval *(*zend_object_read_property_t)(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv); - -/* Used to fetch dimension from the object, read-only */ -typedef zval *(*zend_object_read_dimension_t)(zend_object *object, zval *offset, int type, zval *rv); - - -/* The following rule applies to write_property() and write_dimension() implementations: - If you receive a value zval in write_property/write_dimension, you may only modify it if - its reference count is 1. Otherwise, you must create a copy of that zval before making - any changes. You should NOT modify the reference count of the value passed to you. - You must return the final value of the assigned property. -*/ -/* Used to set property of the object */ -typedef zval *(*zend_object_write_property_t)(zend_object *object, zend_string *member, zval *value, void **cache_slot); - -/* Used to set dimension of the object */ -typedef void (*zend_object_write_dimension_t)(zend_object *object, zval *offset, zval *value); - - -/* Used to create pointer to the property of the object, for future direct r/w access. - * May return one of: - * * A zval pointer, without incrementing the reference count. - * * &EG(error_zval), if an exception has been thrown. - * * NULL, if acquiring a direct pointer is not possible. - * In this case, the VM will fall back to using read_property and write_property. - */ -typedef zval *(*zend_object_get_property_ptr_ptr_t)(zend_object *object, zend_string *member, int type, void **cache_slot); - -/* Used to check if a property of the object exists */ -/* param has_set_exists: - * 0 (has) whether property exists and is not NULL - * 1 (set) whether property exists and is true - * 2 (exists) whether property exists - */ -typedef int (*zend_object_has_property_t)(zend_object *object, zend_string *member, int has_set_exists, void **cache_slot); - -/* Used to check if a dimension of the object exists */ -typedef int (*zend_object_has_dimension_t)(zend_object *object, zval *member, int check_empty); - -/* Used to remove a property of the object */ -typedef void (*zend_object_unset_property_t)(zend_object *object, zend_string *member, void **cache_slot); - -/* Used to remove a dimension of the object */ -typedef void (*zend_object_unset_dimension_t)(zend_object *object, zval *offset); - -/* Used to get hash of the properties of the object, as hash of zval's */ -typedef HashTable *(*zend_object_get_properties_t)(zend_object *object); - -typedef HashTable *(*zend_object_get_debug_info_t)(zend_object *object, int *is_temp); - -typedef enum _zend_prop_purpose { - /* Used for debugging. Supersedes get_debug_info handler. */ - ZEND_PROP_PURPOSE_DEBUG, - /* Used for (array) casts. */ - ZEND_PROP_PURPOSE_ARRAY_CAST, - /* Used for serialization using the "O" scheme. - * Unserialization will use __wakeup(). */ - ZEND_PROP_PURPOSE_SERIALIZE, - /* Used for var_export(). - * The data will be passed to __set_state() when evaluated. */ - ZEND_PROP_PURPOSE_VAR_EXPORT, - /* Used for json_encode(). */ - ZEND_PROP_PURPOSE_JSON, - /* Dummy member to ensure that "default" is specified. */ - _ZEND_PROP_PURPOSE_NON_EXHAUSTIVE_ENUM -} zend_prop_purpose; - -/* The return value must be released using zend_release_properties(). */ -typedef zend_array *(*zend_object_get_properties_for_t)(zend_object *object, zend_prop_purpose purpose); - -/* Used to call methods */ -/* args on stack! */ -/* Andi - EX(fbc) (function being called) needs to be initialized already in the INIT fcall opcode so that the parameters can be parsed the right way. We need to add another callback for this. - */ -typedef zend_function *(*zend_object_get_method_t)(zend_object **object, zend_string *method, const zval *key); -typedef zend_function *(*zend_object_get_constructor_t)(zend_object *object); - -/* Object maintenance/destruction */ -typedef void (*zend_object_dtor_obj_t)(zend_object *object); -typedef void (*zend_object_free_obj_t)(zend_object *object); -typedef zend_object* (*zend_object_clone_obj_t)(zend_object *object); - -/* Get class name for display in var_dump and other debugging functions. - * Must be defined and must return a non-NULL value. */ -typedef zend_string *(*zend_object_get_class_name_t)(const zend_object *object); - -typedef int (*zend_object_compare_t)(zval *object1, zval *object2); - -/* Cast an object to some other type. - * readobj and retval must point to distinct zvals. - */ -typedef int (*zend_object_cast_t)(zend_object *readobj, zval *retval, int type); - -/* updates *count to hold the number of elements present and returns SUCCESS. - * Returns FAILURE if the object does not have any sense of overloaded dimensions */ -typedef int (*zend_object_count_elements_t)(zend_object *object, zend_long *count); - -typedef int (*zend_object_get_closure_t)(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, zend_bool check_only); - -typedef HashTable *(*zend_object_get_gc_t)(zend_object *object, zval **table, int *n); - -typedef int (*zend_object_do_operation_t)(zend_uchar opcode, zval *result, zval *op1, zval *op2); - -struct _zend_object_handlers { - /* offset of real object header (usually zero) */ - int offset; - /* object handlers */ - zend_object_free_obj_t free_obj; /* required */ - zend_object_dtor_obj_t dtor_obj; /* required */ - zend_object_clone_obj_t clone_obj; /* optional */ - zend_object_read_property_t read_property; /* required */ - zend_object_write_property_t write_property; /* required */ - zend_object_read_dimension_t read_dimension; /* required */ - zend_object_write_dimension_t write_dimension; /* required */ - zend_object_get_property_ptr_ptr_t get_property_ptr_ptr; /* required */ - zend_object_has_property_t has_property; /* required */ - zend_object_unset_property_t unset_property; /* required */ - zend_object_has_dimension_t has_dimension; /* required */ - zend_object_unset_dimension_t unset_dimension; /* required */ - zend_object_get_properties_t get_properties; /* required */ - zend_object_get_method_t get_method; /* required */ - zend_object_get_constructor_t get_constructor; /* required */ - zend_object_get_class_name_t get_class_name; /* required */ - zend_object_cast_t cast_object; /* optional */ - zend_object_count_elements_t count_elements; /* optional */ - zend_object_get_debug_info_t get_debug_info; /* optional */ - zend_object_get_closure_t get_closure; /* optional */ - zend_object_get_gc_t get_gc; /* required */ - zend_object_do_operation_t do_operation; /* optional */ - zend_object_compare_t compare; /* optional */ - zend_object_get_properties_for_t get_properties_for; /* optional */ -}; - -/* zend_llist.h*/ -typedef struct _zend_llist_element { - struct _zend_llist_element *next; - struct _zend_llist_element *prev; - char data[1]; /* Needs to always be last in the struct */ -} zend_llist_element; - -typedef void (*llist_dtor_func_t)(void *); -typedef int (*llist_compare_func_t)(const zend_llist_element **, const zend_llist_element **); -typedef void (*llist_apply_with_args_func_t)(void *data, int num_args, va_list args); -typedef void (*llist_apply_with_arg_func_t)(void *data, void *arg); -typedef void (*llist_apply_func_t)(void *); - -typedef struct _zend_llist { - zend_llist_element *head; - zend_llist_element *tail; - size_t count; - size_t size; - llist_dtor_func_t dtor; - unsigned char persistent; - zend_llist_element *traverse_ptr; -} zend_llist; - -typedef zend_llist_element* zend_llist_position; - -/* zend_multibyte.h */ -typedef struct _zend_encoding zend_encoding; - -/* zend_stack.h */ -typedef struct _zend_stack { - int size, top, max; - void *elements; -} zend_stack; - -/* zend_globals.h */ -typedef struct _zend_vm_stack *zend_vm_stack; -typedef struct _zend_ini_entry zend_ini_entry; - -typedef enum { - ON_TOKEN, - ON_FEEDBACK, - ON_STOP -} zend_php_scanner_event; - -/* zend_execute.h */ -typedef struct _zend_vm_stack { - zval *top; - zval *end; - zend_vm_stack prev; -}; - -/* zend_API.h */ -typedef struct _zend_function_entry { - const char *fname; - zif_handler handler; - const struct _zend_internal_arg_info *arg_info; - uint32_t num_args; - uint32_t flags; -} zend_function_entry; - -typedef struct _zend_fcall_info { - size_t size; - zval function_name; - zval *retval; - zval *params; - zend_object *object; - zend_bool no_separation; - uint32_t param_count; -} zend_fcall_info; - -typedef struct _zend_fcall_info_cache { - zend_function *function_handler; - zend_class_entry *calling_scope; - zend_class_entry *called_scope; - zend_object *object; -} zend_fcall_info_cache; - -/* zend_iterators.h */ -typedef struct _zend_object_iterator zend_object_iterator; - -typedef struct _zend_object_iterator_funcs { - /* release all resources associated with this iterator instance */ - void (*dtor)(zend_object_iterator *iter); - - /* check for end of iteration (FAILURE or SUCCESS if data is valid) */ - int (*valid)(zend_object_iterator *iter); - - /* fetch the item data for the current element */ - zval *(*get_current_data)(zend_object_iterator *iter); - - /* fetch the key for the current element (optional, may be NULL). The key - * should be written into the provided zval* using the ZVAL_* macros. If - * this handler is not provided auto-incrementing integer keys will be - * used. */ - void (*get_current_key)(zend_object_iterator *iter, zval *key); - - /* step forwards to next element */ - void (*move_forward)(zend_object_iterator *iter); - - /* rewind to start of data (optional, may be NULL) */ - void (*rewind)(zend_object_iterator *iter); - - /* invalidate current value/key (optional, may be NULL) */ - void (*invalidate_current)(zend_object_iterator *iter); -} zend_object_iterator_funcs; - -struct _zend_object_iterator { - zend_object std; - zval data; - const zend_object_iterator_funcs *funcs; - zend_ulong index; /* private to fe_reset/fe_fetch opcodes */ -}; - -typedef struct _zend_class_iterator_funcs { - zend_function *zf_new_iterator; - zend_function *zf_valid; - zend_function *zf_current; - zend_function *zf_key; - zend_function *zf_next; - zend_function *zf_rewind; -} zend_class_iterator_funcs; - -/* zend.h */ -struct _zend_serialize_data; -struct _zend_unserialize_data; - -typedef struct _zend_serialize_data zend_serialize_data; -typedef struct _zend_unserialize_data zend_unserialize_data; - -typedef struct _zend_class_name { - zend_string *name; - zend_string *lc_name; -} zend_class_name; - -typedef struct _zend_trait_method_reference { - zend_string *method_name; - zend_string *class_name; -} zend_trait_method_reference; - -typedef struct _zend_trait_precedence { - zend_trait_method_reference trait_method; - uint32_t num_excludes; - zend_string *exclude_class_names[1]; -} zend_trait_precedence; - -typedef struct _zend_trait_alias { - zend_trait_method_reference trait_method; - - /** - * name for method to be added - */ - zend_string *alias; - - /** - * modifiers to be set on trait method - */ - uint32_t modifiers; -} zend_trait_alias; - -struct _zend_class_entry { - char type; - zend_string *name; - /* class_entry or string depending on ZEND_ACC_LINKED */ - union { - zend_class_entry *parent; - zend_string *parent_name; - }; - int refcount; - uint32_t ce_flags; - - int default_properties_count; - int default_static_members_count; - zval *default_properties_table; - zval *default_static_members_table; - zval ** static_members_table; - HashTable function_table; - HashTable properties_info; - HashTable constants_table; - - struct _zend_property_info **properties_info_table; - - zend_function *constructor; - zend_function *destructor; - zend_function *clone; - zend_function *__get; - zend_function *__set; - zend_function *__unset; - zend_function *__isset; - zend_function *__call; - zend_function *__callstatic; - zend_function *__tostring; - zend_function *__debugInfo; - zend_function *__serialize; - zend_function *__unserialize; - - /* allocated only if class implements Iterator or IteratorAggregate interface */ - zend_class_iterator_funcs *iterator_funcs_ptr; - - /* handlers */ - union { - zend_object* (*create_object)(zend_class_entry *class_type); - int (*interface_gets_implemented)(zend_class_entry *iface, zend_class_entry *class_type); /* a class implements this interface */ - }; - zend_object_iterator *(*get_iterator)(zend_class_entry *ce, zval *object, int by_ref); - zend_function *(*get_static_method)(zend_class_entry *ce, zend_string* method); - - /* serializer callbacks */ - int (*serialize)(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data); - int (*unserialize)(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data); - - uint32_t num_interfaces; - uint32_t num_traits; - - /* class_entry or string(s) depending on ZEND_ACC_LINKED */ - union { - zend_class_entry **interfaces; - zend_class_name *interface_names; - }; - - zend_class_name *trait_names; - zend_trait_alias **trait_aliases; - zend_trait_precedence **trait_precedences; - HashTable *attributes; - - union { - struct { - zend_string *filename; - uint32_t line_start; - uint32_t line_end; - zend_string *doc_comment; - } user; - struct { - const struct _zend_function_entry *builtin_functions; - struct _zend_module_entry *module; - } internal; - } info; -}; - -typedef enum { - EH_NORMAL = 0, - EH_THROW -} zend_error_handling_t; - -typedef struct { - zend_error_handling_t handling; - zend_class_entry *exception; - zval user_handler; -} zend_error_handling; - -/* zend_objects_API.h */ -typedef struct _zend_objects_store { - zend_object **object_buckets; - uint32_t top; - uint32_t size; - int free_list_head; -} zend_objects_store; - -/* zend_modules.h */ -struct _zend_ini_entry; -typedef struct _zend_module_entry zend_module_entry; -typedef struct _zend_module_dep zend_module_dep; - -struct _zend_module_entry { - unsigned short size; - unsigned int zend_api; - unsigned char zend_debug; - unsigned char zts; - const struct _zend_ini_entry *ini_entry; - const struct _zend_module_dep *deps; - const char *name; - const struct _zend_function_entry *functions; - int (*module_startup_func)(int type, int module_number); - int (*module_shutdown_func)(int type, int module_number); - int (*request_startup_func)(int type, int module_number); - int (*request_shutdown_func)(int type, int module_number); - void (*info_func)(zend_module_entry *zend_module); - const char *version; - size_t globals_size; -#ifdef ZTS - ts_rsrc_id* globals_id_ptr; -#endif -#ifndef ZTS - void* globals_ptr; -#endif - void (*globals_ctor)(void *global); - void (*globals_dtor)(void *global); - int (*post_deactivate_func)(void); - int module_started; - unsigned char type; - void *handle; - int module_number; - const char *build_id; -}; - -struct _zend_module_dep { - const char *name; /* module name */ - const char *rel; /* version relationship: NULL (exists), lt|le|eq|ge|gt (to given version) */ - const char *version; /* version */ - unsigned char type; /* dependency type */ -}; - -/* zend_gc.h */ -typedef struct _zend_gc_status { - uint32_t runs; - uint32_t collected; - uint32_t threshold; - uint32_t num_roots; -} zend_gc_status; - -typedef struct { - zval *cur; - zval *end; - zval *start; -} zend_get_gc_buffer; - -/* zend_globals.h */ -struct _zend_compiler_globals { - zend_stack loop_var_stack; - - zend_class_entry *active_class_entry; - - zend_string *compiled_filename; - - int zend_lineno; - - zend_op_array *active_op_array; - - HashTable *function_table; /* function symbol table */ - HashTable *class_table; /* class table */ - - HashTable filenames_table; /* List of loaded files */ - - HashTable *auto_globals; /* List of superglobal variables */ - - zend_bool parse_error; - zend_bool in_compilation; - zend_bool short_tags; - - zend_bool unclean_shutdown; - - zend_bool ini_parser_unbuffered_errors; - - zend_llist open_files; - - struct _zend_ini_parser_param *ini_parser_param; - - zend_bool skip_shebang; - zend_bool increment_lineno; - - zend_string *doc_comment; - uint32_t extra_fn_flags; - - uint32_t compiler_options; /* set of ZEND_COMPILE_* constants */ - - zend_oparray_context context; - zend_file_context file_context; - - zend_arena *arena; - - HashTable interned_strings; /* Cache of all interned string */ - - const zend_encoding **script_encoding_list; - size_t script_encoding_list_size; - zend_bool multibyte; - zend_bool detect_unicode; - zend_bool encoding_declared; - - zend_ast *ast; - zend_arena *ast_arena; - - zend_stack delayed_oplines_stack; - HashTable *memoized_exprs; - int memoize_mode; - - void *map_ptr_base; - size_t map_ptr_size; - size_t map_ptr_last; - - HashTable *delayed_variance_obligations; - HashTable *delayed_autoloads; - - uint32_t rtd_key_counter; - - zend_stack short_circuiting_opnums; -}; - -#ifdef ZEND_WIN32 -typedef struct _OSVERSIONINFOEXA { - uint32_t dwOSVersionInfoSize; - uint32_t dwMajorVersion; - uint32_t dwMinorVersion; - uint32_t dwBuildNumber; - uint32_t dwPlatformId; - char szCSDVersion[128]; - uint16_t wServicePackMajor; - uint16_t wServicePackMinor; - uint16_t wSuiteMask; - char wProductType; - char wReserved; -} OSVERSIONINFOEX; -#endif - -struct _zend_executor_globals { - zval uninitialized_zval; - zval error_zval; - - /* symbol table cache */ - zend_array *symtable_cache[/* SYMTABLE_CACHE_SIZE */ 32]; - /* Pointer to one past the end of the symtable_cache */ - zend_array **symtable_cache_limit; - /* Pointer to first unused symtable_cache slot */ - zend_array **symtable_cache_ptr; - - zend_array symbol_table; /* main symbol table */ - - HashTable included_files; /* files already included */ - - void *bailout; - - int error_reporting; - int exit_status; - - HashTable *function_table; /* function symbol table */ - HashTable *class_table; /* class table */ - HashTable *zend_constants; /* constants table */ - - zval *vm_stack_top; // Actually it's _zend_execute_data * - zval *vm_stack_end; // It's _zend_execute_data * - zend_vm_stack vm_stack; - size_t vm_stack_page_size; - - struct _zend_execute_data *current_execute_data; - zend_class_entry *fake_scope; /* used to avoid checks accessing properties */ - - uint32_t jit_trace_num; /* Used by tracing JIT to reference the currently running trace */ - - zend_long precision; - - int ticks_count; - - uint32_t persistent_constants_count; - uint32_t persistent_functions_count; - uint32_t persistent_classes_count; - - HashTable *in_autoload; - zend_bool full_tables_cleanup; - - /* for extended information support */ - zend_bool no_extensions; - - zend_bool vm_interrupt; - zend_bool timed_out; - zend_long hard_timeout; - -#ifdef ZEND_WIN32 - OSVERSIONINFOEX windows_version_info; -#endif - - HashTable regular_list; - HashTable persistent_list; - - int user_error_handler_error_reporting; - zval user_error_handler; - zval user_exception_handler; - zend_stack user_error_handlers_error_reporting; - zend_stack user_error_handlers; - zend_stack user_exception_handlers; - - zend_error_handling_t error_handling; - zend_class_entry *exception_class; - - /* timeout support */ - zend_long timeout_seconds; - - int lambda_count; - - HashTable *ini_directives; - HashTable *modified_ini_directives; - zend_ini_entry *error_reporting_ini_entry; - - zend_objects_store objects_store; - zend_object *exception, *prev_exception; - const zend_op *opline_before_exception; - zend_op exception_op[3]; - - struct _zend_module_entry *current_module; - - zend_bool active; - zend_uchar flags; - - zend_long assertions; - - uint32_t ht_iterators_count; /* number of allocatd slots */ - uint32_t ht_iterators_used; /* number of used slots */ - HashTableIterator *ht_iterators; - HashTableIterator ht_iterators_slots[16]; - - void *saved_fpu_cw_ptr; - -#ifdef XPFPA_HAVE_CW - XPFPA_CW_DATATYPE saved_fpu_cw; -#endif - - zend_function trampoline; - zend_op call_trampoline_op; - - HashTable weakrefs; - - zend_bool exception_ignore_args; - zend_long exception_string_param_max_len; - - zend_get_gc_buffer get_gc_buffer; - - void *reserved[ZEND_MAX_RESERVED_RESOURCES]; -}; -typedef struct _zend_executor_globals zend_executor_globals; - -#ifndef ZTS -ZEND_API zend_executor_globals executor_globals; -ZEND_API struct _zend_compiler_globals compiler_globals; -#endif - -/* stdio.h */ -typedef struct { - int level; /* fill/empty level of buffer */ - unsigned flags; /* File status flags */ - char fd; /* File descriptor */ - unsigned char hold; /* Ungetc char if no buffer */ - int bsize; /* Buffer size */ - unsigned char *buffer; /* Data transfer buffer */ - unsigned char *curp; /* Current active pointer */ - unsigned istemp; /* Temporary file indicator */ - short token; /* Used for validity checking */ -} FILE; - -/* zend_stream.h */ -typedef size_t (*zend_stream_fsizer_t)(void* handle); -typedef ssize_t (*zend_stream_reader_t)(void* handle, char *buf, size_t len); -typedef void (*zend_stream_closer_t)(void* handle); - -typedef enum { - ZEND_HANDLE_FILENAME, - ZEND_HANDLE_FP, - ZEND_HANDLE_STREAM -} zend_stream_type; - -typedef struct _zend_stream { - void *handle; - int isatty; - zend_stream_reader_t reader; - zend_stream_fsizer_t fsizer; - zend_stream_closer_t closer; -} zend_stream; - -typedef struct _zend_file_handle { - union { - FILE *fp; - zend_stream stream; - } handle; - const char *filename; - zend_string *opened_path; - zend_stream_type type; - /* free_filename is used by wincache */ - /* TODO: Clean up filename vs opened_path mess */ - zend_bool free_filename; - char *buf; - size_t len; -} zend_file_handle; - -/* zend_ptr_stack.h */ -typedef struct _zend_ptr_stack { - int top, max; - void **elements; - void **top_element; - zend_bool persistent; -} zend_ptr_stack; - -/* zend_multibyte.h */ -typedef size_t (*zend_encoding_filter)(unsigned char **str, size_t *str_length, const unsigned char *buf, size_t length); - -/* zend_language_scanner.h */ -typedef struct _zend_lex_state { - unsigned int yy_leng; - unsigned char *yy_start; - unsigned char *yy_text; - unsigned char *yy_cursor; - unsigned char *yy_marker; - unsigned char *yy_limit; - int yy_state; - zend_stack state_stack; - zend_ptr_stack heredoc_label_stack; - - zend_file_handle *in; - uint32_t lineno; - zend_string *filename; - - /* original (unfiltered) script */ - unsigned char *script_org; - size_t script_org_size; - - /* filtered script */ - unsigned char *script_filtered; - size_t script_filtered_size; - - /* input/output filters */ - zend_encoding_filter input_filter; - zend_encoding_filter output_filter; - const zend_encoding *script_encoding; - - /* hooks */ - void (*on_event)(zend_php_scanner_event event, int token, int line, void *context); - void *on_event_context; - - zend_ast *ast; - zend_arena *ast_arena; -} zend_lex_state; - -typedef struct _zend_heredoc_label { - char *label; - int length; - int indentation; - zend_bool indentation_uses_spaces; -} zend_heredoc_label; - -/** - * Global hooks and variables - */ -extern ZEND_API zend_ast_process_t zend_ast_process; -extern ZEND_API HashTable module_registry; - -/** - * Zend Hash API - */ -ZEND_API int ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string *key); -ZEND_API zval ZEND_FASTCALL *zend_hash_find(const HashTable *ht, zend_string *key); -ZEND_API zval ZEND_FASTCALL *zend_hash_add_or_update(HashTable *ht, zend_string *key, zval *pData, uint32_t flag); - -/** - * Opcode API - */ -ZEND_API int zend_set_user_opcode_handler(zend_uchar opcode, user_opcode_handler_t handler); -ZEND_API user_opcode_handler_t zend_get_user_opcode_handler(zend_uchar opcode); - -/** - * Zend inheritance API - */ -ZEND_API void zend_do_inheritance_ex(zend_class_entry *ce, zend_class_entry *parent_ce, zend_bool checked); -ZEND_API zend_object ZEND_FASTCALL *zend_objects_new(zend_class_entry *ce); -ZEND_API void ZEND_FASTCALL zend_object_std_init(zend_object *object, zend_class_entry *ce); -ZEND_API void object_properties_init(zend_object *object, zend_class_entry *class_type); - -/** - * Language scanner API - */ -ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state); -ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state); -ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename); -ZEND_API void zend_lex_tstring(zval *zv); - -/** - * Abstract Syntax Tree (AST) API - */ -ZEND_API int zendparse(void); -ZEND_API void ZEND_FASTCALL zend_ast_destroy(zend_ast *ast); -ZEND_API zend_ast ZEND_FASTCALL *zend_ast_create_list_0(zend_ast_kind kind); -ZEND_API zend_ast ZEND_FASTCALL *zend_ast_list_add(zend_ast *list, zend_ast *op); -ZEND_API zend_ast ZEND_FASTCALL *zend_ast_create_zval_ex(zval *zv, zend_ast_attr attr); -ZEND_API zend_ast ZEND_FASTCALL *zend_ast_create_0(zend_ast_kind kind); -ZEND_API zend_ast ZEND_FASTCALL *zend_ast_create_1(zend_ast_kind kind, zend_ast *child); -ZEND_API zend_ast ZEND_FASTCALL *zend_ast_create_2(zend_ast_kind kind, zend_ast *child1, zend_ast *child2); -ZEND_API zend_ast ZEND_FASTCALL *zend_ast_create_3(zend_ast_kind kind, zend_ast *child1, zend_ast *child2, zend_ast *child3); -ZEND_API zend_ast ZEND_FASTCALL *zend_ast_create_4( - zend_ast_kind kind, zend_ast *child1, zend_ast *child2, - zend_ast *child3, zend_ast *child4 -); -ZEND_API zend_ast *zend_ast_create_decl( - zend_ast_kind kind, uint32_t flags, uint32_t start_lineno, zend_string *doc_comment, - zend_string *name, zend_ast *child0, zend_ast *child1, zend_ast *child2, zend_ast *child3 -); - -/** - * Modules API - */ -ZEND_API zend_module_entry* zend_register_module_ex(zend_module_entry *module); -ZEND_API int zend_startup_module_ex(zend_module_entry *module); diff --git a/include/process.php b/include/process.php new file mode 100644 index 0000000..3d34804 --- /dev/null +++ b/include/process.php @@ -0,0 +1,138 @@ +loadXML(`echo $cCode|cpp $(php-config --includes) -P -C -D"__attribute__(ARGS)=" - |srcml --language C`); +// Remove all comments +/** + * @var DOMNode $comment + */ +foreach(iterator_to_array($xml->getElementsByTagName("comment")) as $comment) { + /** + * @var DOMNode $parent + */ + $parent = $comment->parentNode; + $parent->removeChild($comment); +} + +$version = PHP_MAJOR_VERSION."_" . PHP_MINOR_VERSION . "_" . (PHP_INT_SIZE === 8 ? "x64" : "x32") . "_" . (ZEND_THREAD_SAFE ? "zts" : "nts"); + +$symbols = []; + +/** + * @var DOMElement $typedef + */ +foreach(iterator_to_array($xml->getElementsByTagName("typedef")) as $typedef) { + /** + * @var list $children + */ + $children = array_values(array_filter(iterator_to_array($typedef->childNodes), fn(DOMNode $dn): bool => $dn instanceof DOMElement)); + if(count($children) === 2 && $children[0]->localName === "type" && $children[1]->localName === "name") { + // Simple typedef: typedef ... zend_uchar; + // Also handles typedef union + $symbols[$children[1]->textContent] = $typedef->textContent; + } + if(count($children) === 1 && $children[0]->localName === "function_decl") { + // Function declaration typedef: typedef ...(*)compare_func_t... + $nameNode = array_values(array_filter(iterator_to_array($children[0]->childNodes), fn(DOMNode $dn) => $dn instanceof DOMElement && $dn->localName === "name"))[0]; + if($nameNode instanceof DOMElement) { + $symbols[$nameNode->textContent] = $typedef->textContent; + } + } +} +/** + * @var DOMElement $struct + */ +foreach([...iterator_to_array($xml->getElementsByTagName("struct_decl")), ...iterator_to_array($xml->getElementsByTagName("struct"))] as $struct) { + + /** + * @var list $children + */ + $children = array_values(array_filter(iterator_to_array($struct->childNodes), fn(DOMNode $dn): bool => $dn instanceof DOMElement)); + if($children[0]->localName === "name") { + $symbols[$children[0]->textContent] = $struct->textContent; + } +} +/** + * @var DOMElement $union + */ +foreach(iterator_to_array($xml->getElementsByTagName("union")) as $union) { + + /** + * @var list $children + */ + $children = array_values(array_filter(iterator_to_array($union->childNodes), fn(DOMNode $dn): bool => $dn instanceof DOMElement)); + if($children[0]->localName === "name") { + $symbols[$children[0]->textContent] = $union->textContent; + } +} +/** + * @var DOMElement $declare + */ +foreach(iterator_to_array($xml->getElementsByTagName("decl_stmt")) as $declare) { + // ... std_object_handlers; + + /** + * @var list $children + */ + $children = array_values(array_filter(iterator_to_array($declare->childNodes), fn(DOMNode $dn): bool => $dn instanceof DOMElement)); + if(count($children) === 1 && $children[0]->localName === "decl") { + $children = array_values(array_filter(iterator_to_array($children[0]->childNodes), fn(DOMNode $dn): bool => $dn instanceof DOMElement)); + if(count($children) === 2 && $children[0]->localName === "type" && $children[1]->localName === "name") { + $symbols[$children[1]->textContent] = $declare->textContent; + } + } +} + + +/** + * @var DOMElement $struct + */ +foreach(iterator_to_array($xml->getElementsByTagName("function_decl")) as $func) { + // ... std_object_handlers; + + /** + * @var list $children + */ + $children = array_values(array_filter(iterator_to_array($func->childNodes), fn(DOMNode $dn): bool => $dn instanceof DOMElement)); + if($children[0]->localName === "type" && $children[1]->localName === "name") { + $symbols[$children[1]->textContent] = $func->textContent; + } +} + +// Remove duplicate newlines +$symbols = array_map(fn(string $s) => preg_replace('/^[ \t]*[\r\n]+/m', '', $s), $symbols); + +$fname = __DIR__ . "/engine_$version.h"; +$f = fopen($fname, "w"); + +fwrite($f, "#define FFI_SCOPE \"ZEngine\"\n#define FFI_LIB \"ZEND_LIBRARY_NAME\"\n"); +foreach(file(__DIR__ . "/symbols_$version.txt") as $desired_symbol) { + $desired_symbol = trim($desired_symbol); + if(empty($desired_symbol)) continue; + $symbol = $symbols[$desired_symbol] ?? null; + if(is_null($symbol)) { + throw new RuntimeException("Could not find symbol $desired_symbol"); + } + fwrite($f, "$symbol\n"); +} +fclose($f); + +FFI::cdef(file_get_contents($fname)); + +//echo json_encode($symbols, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT); +// Turn into headers again: srcml out.xml | grep . +//$xml->save(__DIR__ . "/out.xml"); \ No newline at end of file diff --git a/include/symbols_7_4_x64_nts.txt b/include/symbols_7_4_x64_nts.txt new file mode 100644 index 0000000..c77bed9 --- /dev/null +++ b/include/symbols_7_4_x64_nts.txt @@ -0,0 +1,194 @@ +zend_long +zend_ulong +zend_off_t +zend_bool +zend_uchar +zend_type +ZEND_RESULT_CODE +zend_object_handlers +zend_class_entry +zend_function +zend_execute_data +zval +zend_refcounted +zend_string +zend_array +zend_object +zend_resource +zend_reference +zend_ast_ref +zend_ast +compare_func_t +swap_func_t +sort_func_t +dtor_func_t +copy_ctor_func_t +zend_value +_zval_struct +zend_refcounted_h +_zend_refcounted +_zend_string +Bucket +HashTable +_zend_array +HashPosition +HashTableIterator +_zend_object +_zend_resource +zend_property_info_list +zend_property_info_source_list +_zend_reference +_zend_ast_ref +zend_ast_kind +zend_ast_attr +_zend_ast +zend_ast_list +zend_ast_zval +zend_ast_decl +zend_ast_process_t +zend_intptr_t +zend_uintptr_t +zend_arena +_zend_arena +zend_op_array +zend_op +znode_op +znode +zend_ast_znode +zend_declarables +zend_file_context +zend_parser_stack_elem +user_opcode_handler_t +_zend_op +zend_brk_cont_element +zend_label +zend_try_catch_element +zend_live_range +zend_oparray_context +zend_property_info +zend_class_constant +zend_internal_arg_info +zend_arg_info +zend_internal_function_info +_zend_op_array +zif_handler +zend_internal_function +_zend_function +_zend_execute_data +zend_closure +std_object_handlers +zend_object_read_property_t +zend_object_read_dimension_t +zend_object_write_property_t +zend_object_write_dimension_t +zend_object_get_property_ptr_ptr_t +zend_object_has_property_t +zend_object_has_dimension_t +zend_object_unset_property_t +zend_object_unset_dimension_t +zend_object_get_properties_t +zend_object_get_debug_info_t +zend_prop_purpose +zend_object_get_properties_for_t +zend_object_get_method_t +zend_object_get_constructor_t +zend_object_dtor_obj_t +zend_object_free_obj_t +zend_object_clone_obj_t +zend_object_get_class_name_t +zend_object_compare_t +zend_object_cast_t +zend_object_count_elements_t +zend_object_get_closure_t +zend_object_get_gc_t +zend_object_do_operation_t +zend_object_get_t +zend_object_set_t +zend_object_call_method_t +zend_object_compare_zvals_t +_zend_object_handlers +zend_llist_element +llist_dtor_func_t +llist_compare_func_t +llist_apply_with_args_func_t +llist_apply_with_arg_func_t +llist_apply_func_t +zend_llist +zend_llist_position +zend_encoding +zend_stack +zend_vm_stack +zend_ini_entry +zend_php_scanner_event +_zend_vm_stack +zend_function_entry +zend_fcall_info +zend_fcall_info_cache +zend_object_iterator +zend_object_iterator_funcs +_zend_object_iterator +zend_class_iterator_funcs +_zend_serialize_data +_zend_unserialize_data +zend_serialize_data +zend_unserialize_data +zend_class_name +zend_trait_method_reference +zend_trait_precedence +zend_trait_alias +_zend_class_entry +zend_error_handling_t +zend_error_handling +zend_objects_store +_zend_ini_entry +zend_module_entry +zend_module_dep +_zend_module_entry +_zend_module_dep +zend_gc_status +_zend_compiler_globals +jmp_buf +fpu_control_t +_zend_executor_globals +zend_executor_globals +executor_globals +compiler_globals +FILE +zend_stream_fsizer_t +zend_stream_reader_t +zend_stream_closer_t +zend_stream_type +zend_stream +zend_file_handle +zend_ptr_stack +zend_encoding_filter +zend_lex_state +zend_heredoc_label +zend_ast_process +module_registry +zend_hash_del +zend_hash_find +zend_hash_add_or_update +zend_set_user_opcode_handler +zend_get_user_opcode_handler +zend_do_inheritance_ex +zend_objects_new +zend_object_std_init +object_properties_init +zend_save_lexical_state +zend_restore_lexical_state +zend_prepare_string_for_scanning +zend_lex_tstring +zendparse +zend_ast_destroy +zend_ast_create_list_0 +zend_ast_list_add +zend_ast_create_zval_ex +zend_ast_create_0 +zend_ast_create_1 +zend_ast_create_2 +zend_ast_create_3 +zend_ast_create_4 +zend_ast_create_decl +zend_register_module_ex +zend_startup_module_ex diff --git a/include/symbols_7_4_x64_zts.txt b/include/symbols_7_4_x64_zts.txt new file mode 100644 index 0000000..1c2b311 --- /dev/null +++ b/include/symbols_7_4_x64_zts.txt @@ -0,0 +1,193 @@ +zend_long +zend_ulong +zend_off_t +zend_bool +zend_uchar +zend_type +ZEND_RESULT_CODE +zend_object_handlers +zend_class_entry +zend_function +zend_execute_data +zval +zend_refcounted +zend_string +zend_array +zend_object +zend_resource +zend_reference +zend_ast_ref +zend_ast +compare_func_t +swap_func_t +sort_func_t +dtor_func_t +copy_ctor_func_t +zend_value +_zval_struct +zend_refcounted_h +_zend_refcounted +_zend_string +Bucket +HashTable +_zend_array +HashPosition +HashTableIterator +_zend_object +_zend_resource +zend_property_info_list +zend_property_info_source_list +_zend_reference +_zend_ast_ref +zend_ast_kind +zend_ast_attr +_zend_ast +zend_ast_list +zend_ast_zval +zend_ast_decl +zend_ast_process_t +zend_intptr_t +zend_uintptr_t +zend_arena +_zend_arena +zend_op_array +zend_op +znode_op +znode +zend_ast_znode +zend_declarables +zend_file_context +zend_parser_stack_elem +user_opcode_handler_t +_zend_op +zend_brk_cont_element +zend_label +zend_try_catch_element +zend_live_range +zend_oparray_context +zend_property_info +zend_class_constant +zend_internal_arg_info +zend_arg_info +zend_internal_function_info +_zend_op_array +zif_handler +zend_internal_function +_zend_function +_zend_execute_data +zend_closure +std_object_handlers +zend_object_read_property_t +zend_object_read_dimension_t +zend_object_write_property_t +zend_object_write_dimension_t +zend_object_get_property_ptr_ptr_t +zend_object_has_property_t +zend_object_has_dimension_t +zend_object_unset_property_t +zend_object_unset_dimension_t +zend_object_get_properties_t +zend_object_get_debug_info_t +zend_prop_purpose +zend_object_get_properties_for_t +zend_object_get_method_t +zend_object_get_constructor_t +zend_object_dtor_obj_t +zend_object_free_obj_t +zend_object_clone_obj_t +zend_object_get_class_name_t +zend_object_compare_t +zend_object_cast_t +zend_object_count_elements_t +zend_object_get_closure_t +zend_object_get_gc_t +zend_object_do_operation_t +zend_object_get_t +zend_object_set_t +zend_object_call_method_t +zend_object_compare_zvals_t +_zend_object_handlers +zend_llist_element +llist_dtor_func_t +llist_compare_func_t +llist_apply_with_args_func_t +llist_apply_with_arg_func_t +llist_apply_func_t +zend_llist +zend_llist_position +zend_encoding +zend_stack +zend_vm_stack +zend_ini_entry +zend_php_scanner_event +_zend_vm_stack +zend_function_entry +zend_fcall_info +zend_fcall_info_cache +zend_object_iterator +zend_object_iterator_funcs +_zend_object_iterator +zend_class_iterator_funcs +_zend_serialize_data +_zend_unserialize_data +zend_serialize_data +zend_unserialize_data +zend_class_name +zend_trait_method_reference +zend_trait_precedence +zend_trait_alias +_zend_class_entry +zend_error_handling_t +zend_error_handling +zend_objects_store +_zend_ini_entry +zend_module_entry +zend_module_dep +ts_rsrc_id +_zend_module_entry +_zend_module_dep +zend_gc_status +_zend_compiler_globals +jmp_buf +fpu_control_t +_zend_executor_globals +zend_executor_globals +FILE +zend_stream_fsizer_t +zend_stream_reader_t +zend_stream_closer_t +zend_stream_type +zend_stream +zend_file_handle +zend_ptr_stack +zend_encoding_filter +zend_lex_state +zend_heredoc_label +zend_ast_process +module_registry +zend_hash_del +zend_hash_find +zend_hash_add_or_update +zend_set_user_opcode_handler +zend_get_user_opcode_handler +zend_do_inheritance_ex +zend_objects_new +zend_object_std_init +object_properties_init +zend_save_lexical_state +zend_restore_lexical_state +zend_prepare_string_for_scanning +zend_lex_tstring +zendparse +zend_ast_destroy +zend_ast_create_list_0 +zend_ast_list_add +zend_ast_create_zval_ex +zend_ast_create_0 +zend_ast_create_1 +zend_ast_create_2 +zend_ast_create_3 +zend_ast_create_4 +zend_ast_create_decl +zend_register_module_ex +zend_startup_module_ex diff --git a/include/symbols_8_0_x64_nts.txt b/include/symbols_8_0_x64_nts.txt new file mode 100644 index 0000000..4329e99 --- /dev/null +++ b/include/symbols_8_0_x64_nts.txt @@ -0,0 +1,192 @@ +zend_long +zend_ulong +zend_off_t +zend_bool +zend_uchar +zend_type +ZEND_RESULT_CODE +zend_object_handlers +zend_class_entry +zend_function +zend_execute_data +zval +zend_refcounted +zend_string +zend_array +zend_object +zend_resource +zend_reference +zend_ast_ref +zend_ast +compare_func_t +swap_func_t +sort_func_t +dtor_func_t +copy_ctor_func_t +zend_value +_zval_struct +zend_refcounted_h +_zend_refcounted +_zend_string +Bucket +HashTable +_zend_array +HashPosition +HashTableIterator +_zend_object +_zend_resource +zend_property_info_list +zend_property_info_source_list +_zend_reference +_zend_ast_ref +zend_ast_kind +zend_ast_attr +_zend_ast +zend_ast_list +zend_ast_zval +zend_ast_decl +zend_ast_process_t +zend_intptr_t +zend_uintptr_t +zend_arena +_zend_arena +zend_op_array +zend_op +znode_op +znode +zend_ast_znode +zend_declarables +zend_file_context +zend_lexer_ident_ref +zend_parser_stack_elem +user_opcode_handler_t +_zend_op +zend_brk_cont_element +zend_label +zend_try_catch_element +zend_live_range +zend_oparray_context +zend_property_info +zend_class_constant +zend_internal_arg_info +zend_arg_info +zend_internal_function_info +_zend_op_array +zif_handler +zend_internal_function +_zend_function +_zend_execute_data +zend_closure +std_object_handlers +zend_object_read_property_t +zend_object_read_dimension_t +zend_object_write_property_t +zend_object_write_dimension_t +zend_object_get_property_ptr_ptr_t +zend_object_has_property_t +zend_object_has_dimension_t +zend_object_unset_property_t +zend_object_unset_dimension_t +zend_object_get_properties_t +zend_object_get_debug_info_t +zend_prop_purpose +zend_object_get_properties_for_t +zend_object_get_method_t +zend_object_get_constructor_t +zend_object_dtor_obj_t +zend_object_free_obj_t +zend_object_clone_obj_t +zend_object_get_class_name_t +zend_object_compare_t +zend_object_cast_t +zend_object_count_elements_t +zend_object_get_closure_t +zend_object_get_gc_t +zend_object_do_operation_t +_zend_object_handlers +zend_llist_element +llist_dtor_func_t +llist_compare_func_t +llist_apply_with_args_func_t +llist_apply_with_arg_func_t +llist_apply_func_t +zend_llist +zend_llist_position +zend_encoding +zend_stack +zend_vm_stack +zend_ini_entry +zend_php_scanner_event +_zend_vm_stack +zend_function_entry +zend_fcall_info +zend_fcall_info_cache +zend_object_iterator +zend_object_iterator_funcs +_zend_object_iterator +zend_class_iterator_funcs +_zend_serialize_data +_zend_unserialize_data +zend_serialize_data +zend_unserialize_data +zend_class_name +zend_trait_method_reference +zend_trait_precedence +zend_trait_alias +_zend_class_entry +zend_error_handling_t +zend_error_handling +zend_objects_store +_zend_ini_entry +zend_module_entry +zend_module_dep +zend_result +_zend_module_entry +_zend_module_dep +zend_gc_status +zend_get_gc_buffer +_zend_compiler_globals +jmp_buf +_zend_executor_globals +zend_executor_globals +executor_globals +compiler_globals +FILE +zend_stream_fsizer_t +zend_stream_reader_t +zend_stream_closer_t +zend_stream_type +zend_stream +zend_file_handle +zend_ptr_stack +zend_encoding_filter +zend_lex_state +zend_heredoc_label +zend_ast_process +module_registry +zend_hash_del +zend_hash_find +zend_hash_add_or_update +zend_set_user_opcode_handler +zend_get_user_opcode_handler +zend_do_inheritance_ex +zend_objects_new +zend_object_std_init +object_properties_init +zend_save_lexical_state +zend_restore_lexical_state +zend_prepare_string_for_scanning +zend_lex_tstring +zendparse +zend_ast_destroy +zend_ast_create_list_0 +zend_ast_list_add +zend_ast_create_zval_ex +zend_ast_create_0 +zend_ast_create_1 +zend_ast_create_2 +zend_ast_create_3 +zend_ast_create_4 +zend_ast_create_decl +zend_register_module_ex +zend_startup_module_ex diff --git a/include/symbols_8_0_x64_zts.txt b/include/symbols_8_0_x64_zts.txt new file mode 100644 index 0000000..79e7d7d --- /dev/null +++ b/include/symbols_8_0_x64_zts.txt @@ -0,0 +1,191 @@ +zend_long +zend_ulong +zend_off_t +zend_bool +zend_uchar +zend_type +ZEND_RESULT_CODE +zend_object_handlers +zend_class_entry +zend_function +zend_execute_data +zval +zend_refcounted +zend_string +zend_array +zend_object +zend_resource +zend_reference +zend_ast_ref +zend_ast +compare_func_t +swap_func_t +sort_func_t +dtor_func_t +copy_ctor_func_t +zend_value +_zval_struct +zend_refcounted_h +_zend_refcounted +_zend_string +Bucket +HashTable +_zend_array +HashPosition +HashTableIterator +_zend_object +_zend_resource +zend_property_info_list +zend_property_info_source_list +_zend_reference +_zend_ast_ref +zend_ast_kind +zend_ast_attr +_zend_ast +zend_ast_list +zend_ast_zval +zend_ast_decl +zend_ast_process_t +zend_intptr_t +zend_uintptr_t +zend_arena +_zend_arena +zend_op_array +zend_op +znode_op +znode +zend_ast_znode +zend_declarables +zend_file_context +zend_lexer_ident_ref +zend_parser_stack_elem +user_opcode_handler_t +_zend_op +zend_brk_cont_element +zend_label +zend_try_catch_element +zend_live_range +zend_oparray_context +zend_property_info +zend_class_constant +zend_internal_arg_info +zend_arg_info +zend_internal_function_info +_zend_op_array +zif_handler +zend_internal_function +_zend_function +_zend_execute_data +zend_closure +std_object_handlers +zend_object_read_property_t +zend_object_read_dimension_t +zend_object_write_property_t +zend_object_write_dimension_t +zend_object_get_property_ptr_ptr_t +zend_object_has_property_t +zend_object_has_dimension_t +zend_object_unset_property_t +zend_object_unset_dimension_t +zend_object_get_properties_t +zend_object_get_debug_info_t +zend_prop_purpose +zend_object_get_properties_for_t +zend_object_get_method_t +zend_object_get_constructor_t +zend_object_dtor_obj_t +zend_object_free_obj_t +zend_object_clone_obj_t +zend_object_get_class_name_t +zend_object_compare_t +zend_object_cast_t +zend_object_count_elements_t +zend_object_get_closure_t +zend_object_get_gc_t +zend_object_do_operation_t +_zend_object_handlers +zend_llist_element +llist_dtor_func_t +llist_compare_func_t +llist_apply_with_args_func_t +llist_apply_with_arg_func_t +llist_apply_func_t +zend_llist +zend_llist_position +zend_encoding +zend_stack +zend_vm_stack +zend_ini_entry +zend_php_scanner_event +_zend_vm_stack +zend_function_entry +zend_fcall_info +zend_fcall_info_cache +zend_object_iterator +zend_object_iterator_funcs +_zend_object_iterator +zend_class_iterator_funcs +_zend_serialize_data +_zend_unserialize_data +zend_serialize_data +zend_unserialize_data +zend_class_name +zend_trait_method_reference +zend_trait_precedence +zend_trait_alias +_zend_class_entry +zend_error_handling_t +zend_error_handling +zend_objects_store +_zend_ini_entry +zend_module_entry +zend_module_dep +zend_result +ts_rsrc_id +_zend_module_entry +_zend_module_dep +zend_gc_status +zend_get_gc_buffer +_zend_compiler_globals +jmp_buf +_zend_executor_globals +zend_executor_globals +FILE +zend_stream_fsizer_t +zend_stream_reader_t +zend_stream_closer_t +zend_stream_type +zend_stream +zend_file_handle +zend_ptr_stack +zend_encoding_filter +zend_lex_state +zend_heredoc_label +zend_ast_process +module_registry +zend_hash_del +zend_hash_find +zend_hash_add_or_update +zend_set_user_opcode_handler +zend_get_user_opcode_handler +zend_do_inheritance_ex +zend_objects_new +zend_object_std_init +object_properties_init +zend_save_lexical_state +zend_restore_lexical_state +zend_prepare_string_for_scanning +zend_lex_tstring +zendparse +zend_ast_destroy +zend_ast_create_list_0 +zend_ast_list_add +zend_ast_create_zval_ex +zend_ast_create_0 +zend_ast_create_1 +zend_ast_create_2 +zend_ast_create_3 +zend_ast_create_4 +zend_ast_create_decl +zend_register_module_ex +zend_startup_module_ex diff --git a/include/symbols_8_1_x64_nts.txt b/include/symbols_8_1_x64_nts.txt new file mode 100644 index 0000000..36a0a96 --- /dev/null +++ b/include/symbols_8_1_x64_nts.txt @@ -0,0 +1,196 @@ +zend_long +zend_ulong +zend_off_t +zend_bool +zend_uchar +zend_type +ZEND_RESULT_CODE +zend_object_handlers +zend_class_entry +zend_function +zend_execute_data +zval +zend_refcounted +zend_string +zend_array +zend_object +zend_resource +zend_reference +zend_ast_ref +zend_ast +compare_func_t +swap_func_t +sort_func_t +dtor_func_t +copy_ctor_func_t +zend_value +_zval_struct +zend_refcounted_h +_zend_refcounted +_zend_string +Bucket +HashTable +_zend_array +HashPosition +HashTableIterator +_zend_object +_zend_resource +zend_property_info_list +zend_property_info_source_list +_zend_reference +_zend_ast_ref +zend_ast_kind +zend_ast_attr +_zend_ast +zend_ast_list +zend_ast_zval +zend_ast_decl +zend_ast_process_t +zend_intptr_t +zend_uintptr_t +zend_arena +_zend_arena +zend_op_array +zend_op +znode_op +znode +zend_ast_znode +zend_declarables +zend_file_context +zend_parser_stack_elem +user_opcode_handler_t +_zend_op +zend_brk_cont_element +zend_label +zend_try_catch_element +zend_live_range +zend_oparray_context +zend_property_info +zend_class_constant +zend_internal_arg_info +zend_arg_info +zend_internal_function_info +_zend_op_array +zif_handler +zend_internal_function +_zend_function +_zend_execute_data +zend_closure +std_object_handlers +zend_object_read_property_t +zend_object_read_dimension_t +zend_object_write_property_t +zend_object_write_dimension_t +zend_object_get_property_ptr_ptr_t +zend_object_has_property_t +zend_object_has_dimension_t +zend_object_unset_property_t +zend_object_unset_dimension_t +zend_object_get_properties_t +zend_object_get_debug_info_t +zend_prop_purpose +zend_object_get_properties_for_t +zend_object_get_method_t +zend_object_get_constructor_t +zend_object_dtor_obj_t +zend_object_free_obj_t +zend_object_clone_obj_t +zend_object_get_class_name_t +zend_object_compare_t +zend_object_cast_t +zend_object_count_elements_t +zend_object_get_closure_t +zend_object_get_gc_t +zend_object_do_operation_t +_zend_object_handlers +zend_llist_element +llist_dtor_func_t +llist_compare_func_t +llist_apply_with_args_func_t +llist_apply_with_arg_func_t +llist_apply_func_t +zend_llist +zend_llist_position +zend_encoding +zend_stack +zend_vm_stack +zend_ini_entry +zend_php_scanner_event +_zend_vm_stack +zend_function_entry +zend_fcall_info +zend_fcall_info_cache +zend_object_iterator +zend_object_iterator_funcs +_zend_object_iterator +zend_class_iterator_funcs +_zend_serialize_data +_zend_unserialize_data +zend_serialize_data +zend_unserialize_data +zend_class_name +zend_trait_method_reference +zend_trait_precedence +zend_trait_alias +zend_class_mutable_data +zend_inheritance_cache_entry +_zend_class_entry +zend_error_handling_t +zend_error_handling +zend_objects_store +_zend_ini_entry +zend_module_entry +zend_module_dep +zend_result +_zend_module_entry +_zend_module_dep +zend_gc_status +zend_get_gc_buffer +_zend_compiler_globals +jmp_buf +zend_fiber +zend_fiber_context +zend_error_info +_zend_executor_globals +zend_executor_globals +executor_globals +compiler_globals +FILE +zend_stream_fsizer_t +zend_stream_reader_t +zend_stream_closer_t +zend_stream_type +zend_stream +zend_file_handle +zend_ptr_stack +zend_encoding_filter +zend_lex_state +zend_heredoc_label +zend_ast_process +module_registry +zend_hash_del +zend_hash_find +zend_hash_add_or_update +zend_set_user_opcode_handler +zend_get_user_opcode_handler +zend_do_inheritance_ex +zend_objects_new +zend_object_std_init +object_properties_init +zend_save_lexical_state +zend_restore_lexical_state +zend_prepare_string_for_scanning +zend_lex_tstring +zendparse +zend_ast_destroy +zend_ast_create_list_0 +zend_ast_list_add +zend_ast_create_zval_ex +zend_ast_create_0 +zend_ast_create_1 +zend_ast_create_2 +zend_ast_create_3 +zend_ast_create_4 +zend_ast_create_decl +zend_register_module_ex +zend_startup_module_ex diff --git a/include/symbols_8_1_x64_zts.txt b/include/symbols_8_1_x64_zts.txt new file mode 100644 index 0000000..62ae0d2 --- /dev/null +++ b/include/symbols_8_1_x64_zts.txt @@ -0,0 +1,195 @@ +zend_long +zend_ulong +zend_off_t +zend_bool +zend_uchar +zend_type +ZEND_RESULT_CODE +zend_object_handlers +zend_class_entry +zend_function +zend_execute_data +zval +zend_refcounted +zend_string +zend_array +zend_object +zend_resource +zend_reference +zend_ast_ref +zend_ast +compare_func_t +swap_func_t +sort_func_t +dtor_func_t +copy_ctor_func_t +zend_value +_zval_struct +zend_refcounted_h +_zend_refcounted +_zend_string +Bucket +HashTable +_zend_array +HashPosition +HashTableIterator +_zend_object +_zend_resource +zend_property_info_list +zend_property_info_source_list +_zend_reference +_zend_ast_ref +zend_ast_kind +zend_ast_attr +_zend_ast +zend_ast_list +zend_ast_zval +zend_ast_decl +zend_ast_process_t +zend_intptr_t +zend_uintptr_t +zend_arena +_zend_arena +zend_op_array +zend_op +znode_op +znode +zend_ast_znode +zend_declarables +zend_file_context +zend_parser_stack_elem +user_opcode_handler_t +_zend_op +zend_brk_cont_element +zend_label +zend_try_catch_element +zend_live_range +zend_oparray_context +zend_property_info +zend_class_constant +zend_internal_arg_info +zend_arg_info +zend_internal_function_info +_zend_op_array +zif_handler +zend_internal_function +_zend_function +_zend_execute_data +zend_closure +std_object_handlers +zend_object_read_property_t +zend_object_read_dimension_t +zend_object_write_property_t +zend_object_write_dimension_t +zend_object_get_property_ptr_ptr_t +zend_object_has_property_t +zend_object_has_dimension_t +zend_object_unset_property_t +zend_object_unset_dimension_t +zend_object_get_properties_t +zend_object_get_debug_info_t +zend_prop_purpose +zend_object_get_properties_for_t +zend_object_get_method_t +zend_object_get_constructor_t +zend_object_dtor_obj_t +zend_object_free_obj_t +zend_object_clone_obj_t +zend_object_get_class_name_t +zend_object_compare_t +zend_object_cast_t +zend_object_count_elements_t +zend_object_get_closure_t +zend_object_get_gc_t +zend_object_do_operation_t +_zend_object_handlers +zend_llist_element +llist_dtor_func_t +llist_compare_func_t +llist_apply_with_args_func_t +llist_apply_with_arg_func_t +llist_apply_func_t +zend_llist +zend_llist_position +zend_encoding +zend_stack +zend_vm_stack +zend_ini_entry +zend_php_scanner_event +_zend_vm_stack +zend_function_entry +zend_fcall_info +zend_fcall_info_cache +zend_object_iterator +zend_object_iterator_funcs +_zend_object_iterator +zend_class_iterator_funcs +_zend_serialize_data +_zend_unserialize_data +zend_serialize_data +zend_unserialize_data +zend_class_name +zend_trait_method_reference +zend_trait_precedence +zend_trait_alias +zend_class_mutable_data +zend_inheritance_cache_entry +_zend_class_entry +zend_error_handling_t +zend_error_handling +zend_objects_store +_zend_ini_entry +zend_module_entry +zend_module_dep +zend_result +ts_rsrc_id +_zend_module_entry +_zend_module_dep +zend_gc_status +zend_get_gc_buffer +_zend_compiler_globals +jmp_buf +zend_fiber +zend_fiber_context +zend_error_info +_zend_executor_globals +zend_executor_globals +FILE +zend_stream_fsizer_t +zend_stream_reader_t +zend_stream_closer_t +zend_stream_type +zend_stream +zend_file_handle +zend_ptr_stack +zend_encoding_filter +zend_lex_state +zend_heredoc_label +zend_ast_process +module_registry +zend_hash_del +zend_hash_find +zend_hash_add_or_update +zend_set_user_opcode_handler +zend_get_user_opcode_handler +zend_do_inheritance_ex +zend_objects_new +zend_object_std_init +object_properties_init +zend_save_lexical_state +zend_restore_lexical_state +zend_prepare_string_for_scanning +zend_lex_tstring +zendparse +zend_ast_destroy +zend_ast_create_list_0 +zend_ast_list_add +zend_ast_create_zval_ex +zend_ast_create_0 +zend_ast_create_1 +zend_ast_create_2 +zend_ast_create_3 +zend_ast_create_4 +zend_ast_create_decl +zend_register_module_ex +zend_startup_module_ex diff --git a/src/Core.php b/src/Core.php index f90a280..13e495b 100644 --- a/src/Core.php +++ b/src/Core.php @@ -244,7 +244,8 @@ public static function init() throw new \RuntimeException('Preload mode requires that you call Core::preload before'); } // If not, then load definitions by hand - $definition = file_get_contents(DefinitionLoader::wrap(__DIR__.'/../include/engine_x64_nts.h')); + $fname = "engine_".PHP_MAJOR_VERSION."_" . PHP_MINOR_VERSION . "_" . (PHP_INT_SIZE === 8 ? "x64" : "x32") . "_" . (ZEND_THREAD_SAFE ? "zts" : "nts") . ".h"; + $definition = file_get_contents(DefinitionLoader::wrap(__DIR__.'/../include/'.$fname)); $arguments = [$definition]; // For Windows platform we should load symbols from the shared php7.dll library @@ -269,7 +270,8 @@ public static function init() */ public static function preload() { - $definition = file_get_contents(DefinitionLoader::wrap(__DIR__.'/../include/engine_x64_nts.h')); + $fname = "engine_".PHP_MAJOR_VERSION."_" . PHP_MINOR_VERSION . "_" . (PHP_INT_SIZE === 8 ? "x64" : "x32") . "_" . (ZEND_THREAD_SAFE ? "zts" : "nts") . ".h"; + $definition = file_get_contents(DefinitionLoader::wrap(__DIR__.'/../include/'.$fname)); try { $tempFile = tempnam(sys_get_temp_dir(), 'php_ffi'); file_put_contents($tempFile, $definition); diff --git a/src/System/Compiler.php b/src/System/Compiler.php index 64ea190..ef38f5b 100644 --- a/src/System/Compiler.php +++ b/src/System/Compiler.php @@ -118,7 +118,7 @@ public function __construct(CData $pointer) $this->pointer = $pointer; $this->classTable = new HashTable($pointer->class_table); $this->functionTable = new HashTable($pointer->function_table); - $this->filenamesTable = new HashTable($pointer->filenames_table); +// $this->filenamesTable = new HashTable($pointer->filenames_table); } /** From cfaa0852725d2a69fccc45ce023f95aec061ba82 Mon Sep 17 00:00:00 2001 From: Katie Volz Date: Tue, 1 Feb 2022 21:51:17 -0500 Subject: [PATCH 2/5] Generate constants from source code --- composer.json | 5 +- include/Dockerfile | 79 +-- include/Dockerfile.php | 27 + include/README | 2 - include/README.md | 25 + include/constants-7-4-x64-nts-linux.php | 428 ++++++++++++++ include/constants-7-4-x64-zts-linux.php | 428 ++++++++++++++ include/constants-8-0-x64-nts-linux.php | 446 +++++++++++++++ include/constants-8-0-x64-zts-linux.php | 446 +++++++++++++++ include/constants-8-1-x64-nts-linux.php | 455 +++++++++++++++ include/constants-8-1-x64-zts-linux.php | 455 +++++++++++++++ include/constants.php | 3 + ...4_x64_nts.h => engine-7-4-x64-nts-linux.h} | 3 +- ...4_x64_zts.h => engine-7-4-x64-zts-linux.h} | 6 +- ...0_x64_nts.h => engine-8-0-x64-nts-linux.h} | 3 +- ...0_x64_zts.h => engine-8-0-x64-zts-linux.h} | 6 +- ...1_x64_nts.h => engine-8-1-x64-nts-linux.h} | 3 +- ...1_x64_zts.h => engine-8-1-x64-zts-linux.h} | 6 +- include/engine.php | 3 + include/process.php | 130 ++++- include/symbols.txt | 537 ++++++++++++++++++ include/symbols_7_4_x64_nts.txt | 194 ------- include/symbols_7_4_x64_zts.txt | 193 ------- include/symbols_8_0_x64_nts.txt | 192 ------- include/symbols_8_0_x64_zts.txt | 191 ------- include/symbols_8_1_x64_nts.txt | 196 ------- include/symbols_8_1_x64_zts.txt | 195 ------- phpunit.xml.dist | 4 +- src/AbstractSyntaxTree/NodeFactory.php | 4 +- src/AbstractSyntaxTree/NodeKind.php | 219 +++---- src/Core.php | 155 ++--- src/EngineExtension/AbstractModule.php | 11 +- src/EngineExtension/ModuleDependency.php | 7 +- src/Macro/DefinitionLoader.php | 129 ----- src/Reflection/ReflectionClass.php | 21 +- src/Reflection/ReflectionClassConstant.php | 20 +- src/Reflection/ReflectionExtension.php | 6 +- src/Reflection/ReflectionMethod.php | 6 +- src/Reflection/ReflectionValue.php | 49 +- src/System/Compiler.php | 43 +- src/System/ObjectStore.php | 3 +- src/System/OpCode.php | 401 ++++++------- src/Type/HashTable.php | 13 +- src/Type/OpLine.php | 11 +- src/Type/ReferenceCountedInterface.php | 12 +- tests/Reflection/ReflectionFunctionTest.php | 6 +- 46 files changed, 3952 insertions(+), 1825 deletions(-) create mode 100644 include/Dockerfile.php delete mode 100644 include/README create mode 100644 include/README.md create mode 100644 include/constants-7-4-x64-nts-linux.php create mode 100644 include/constants-7-4-x64-zts-linux.php create mode 100644 include/constants-8-0-x64-nts-linux.php create mode 100644 include/constants-8-0-x64-zts-linux.php create mode 100644 include/constants-8-1-x64-nts-linux.php create mode 100644 include/constants-8-1-x64-zts-linux.php create mode 100644 include/constants.php rename include/{engine_7_4_x64_nts.h => engine-7-4-x64-nts-linux.h} (99%) rename include/{engine_7_4_x64_zts.h => engine-7-4-x64-zts-linux.h} (99%) rename include/{engine_8_0_x64_nts.h => engine-8-0-x64-nts-linux.h} (99%) rename include/{engine_8_0_x64_zts.h => engine-8-0-x64-zts-linux.h} (99%) rename include/{engine_8_1_x64_nts.h => engine-8-1-x64-nts-linux.h} (99%) rename include/{engine_8_1_x64_zts.h => engine-8-1-x64-zts-linux.h} (99%) create mode 100644 include/engine.php create mode 100644 include/symbols.txt delete mode 100644 include/symbols_7_4_x64_nts.txt delete mode 100644 include/symbols_7_4_x64_zts.txt delete mode 100644 include/symbols_8_0_x64_nts.txt delete mode 100644 include/symbols_8_0_x64_zts.txt delete mode 100644 include/symbols_8_1_x64_nts.txt delete mode 100644 include/symbols_8_1_x64_zts.txt delete mode 100644 src/Macro/DefinitionLoader.php diff --git a/composer.json b/composer.json index 9c8f3ba..97e9599 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,10 @@ "autoload": { "psr-4" : { "ZEngine\\" : "src/" - } + }, + "files": [ + "include/constants.php" + ] }, "autoload-dev": { "psr-4" : { diff --git a/include/Dockerfile b/include/Dockerfile index f731dbf..6f22670 100644 --- a/include/Dockerfile +++ b/include/Dockerfile @@ -1,80 +1,85 @@ -FROM php:8.1.0-bullseye AS php-8_1_x64_nts-build +FROM php:8.1.0-zts-bullseye AS php-8-1-x64-zts-linux-build RUN apt update RUN apt install libffi-dev RUN docker-php-ext-install ffi RUN curl http://131.123.42.38/lmcrs/v1.0.0/srcml_1.0.0-1_ubuntu20.04.deb > srcml.deb RUN apt install -y ./srcml.deb COPY process.php . -COPY symbols_8_1_x64_nts.txt . -RUN php process.php -FROM scratch AS php-8_1_x64_nts -COPY --from=php-8_1_x64_nts-build /engine_8_1_x64_nts.h /engine_8_1_x64_nts.h +COPY symbols.txt . +RUN php process.php linux +FROM scratch AS php-8-1-x64-zts-linux +COPY --from=php-8-1-x64-zts-linux-build /engine-8-1-x64-zts-linux.h / +COPY --from=php-8-1-x64-zts-linux-build /constants-8-1-x64-zts-linux.php / -FROM php:8.1.0-zts-bullseye AS php-8_1_x64_zts-build +FROM php:8.1.0-bullseye AS php-8-1-x64-nts-linux-build RUN apt update RUN apt install libffi-dev RUN docker-php-ext-install ffi RUN curl http://131.123.42.38/lmcrs/v1.0.0/srcml_1.0.0-1_ubuntu20.04.deb > srcml.deb RUN apt install -y ./srcml.deb COPY process.php . -COPY symbols_8_1_x64_zts.txt . -RUN php process.php -FROM scratch AS php-8_1_x64_zts -COPY --from=php-8_1_x64_zts-build /engine_8_1_x64_zts.h / +COPY symbols.txt . +RUN php process.php linux +FROM scratch AS php-8-1-x64-nts-linux +COPY --from=php-8-1-x64-nts-linux-build /engine-8-1-x64-nts-linux.h / +COPY --from=php-8-1-x64-nts-linux-build /constants-8-1-x64-nts-linux.php / -FROM php:8.0.0-buster AS php-8_0_x64_nts-build +FROM php:8.0.0-zts-buster AS php-8-0-x64-zts-linux-build RUN apt update RUN apt install libffi-dev RUN docker-php-ext-install ffi RUN curl http://131.123.42.38/lmcrs/v1.0.0/srcml_1.0.0-1_ubuntu19.04.deb > srcml.deb RUN apt install -y ./srcml.deb COPY process.php . -COPY symbols_8_0_x64_nts.txt . -RUN php process.php -FROM scratch AS php-8_0_x64_nts -COPY --from=php-8_0_x64_nts-build /engine_8_0_x64_nts.h /engine_8_0_x64_nts.h +COPY symbols.txt . +RUN php process.php linux +FROM scratch AS php-8-0-x64-zts-linux +COPY --from=php-8-0-x64-zts-linux-build /engine-8-0-x64-zts-linux.h / +COPY --from=php-8-0-x64-zts-linux-build /constants-8-0-x64-zts-linux.php / -FROM php:8.0.0-zts-buster AS php-8_0_x64_zts-build +FROM php:8.0.0-buster AS php-8-0-x64-nts-linux-build RUN apt update RUN apt install libffi-dev RUN docker-php-ext-install ffi RUN curl http://131.123.42.38/lmcrs/v1.0.0/srcml_1.0.0-1_ubuntu19.04.deb > srcml.deb RUN apt install -y ./srcml.deb COPY process.php . -COPY symbols_8_0_x64_zts.txt . -RUN php process.php -FROM scratch AS php-8_0_x64_zts -COPY --from=php-8_0_x64_zts-build /engine_8_0_x64_zts.h / +COPY symbols.txt . +RUN php process.php linux +FROM scratch AS php-8-0-x64-nts-linux +COPY --from=php-8-0-x64-nts-linux-build /engine-8-0-x64-nts-linux.h / +COPY --from=php-8-0-x64-nts-linux-build /constants-8-0-x64-nts-linux.php / -FROM php:7.4.0-buster AS php-7_4_x64_nts-build +FROM php:7.4.0-zts-buster AS php-7-4-x64-zts-linux-build RUN apt update RUN apt install libffi-dev RUN docker-php-ext-install ffi RUN curl http://131.123.42.38/lmcrs/v1.0.0/srcml_1.0.0-1_ubuntu19.04.deb > srcml.deb RUN apt install -y ./srcml.deb COPY process.php . -COPY symbols_7_4_x64_nts.txt . -RUN php process.php -FROM scratch AS php-7_4_x64_nts -COPY --from=php-7_4_x64_nts-build /engine_7_4_x64_nts.h /engine_7_4_x64_nts.h +COPY symbols.txt . +RUN php process.php linux +FROM scratch AS php-7-4-x64-zts-linux +COPY --from=php-7-4-x64-zts-linux-build /engine-7-4-x64-zts-linux.h / +COPY --from=php-7-4-x64-zts-linux-build /constants-7-4-x64-zts-linux.php / -FROM php:7.4.0-zts-buster AS php-7_4_x64_zts-build +FROM php:7.4.0-buster AS php-7-4-x64-nts-linux-build RUN apt update RUN apt install libffi-dev RUN docker-php-ext-install ffi RUN curl http://131.123.42.38/lmcrs/v1.0.0/srcml_1.0.0-1_ubuntu19.04.deb > srcml.deb RUN apt install -y ./srcml.deb COPY process.php . -COPY symbols_7_4_x64_zts.txt . -RUN php process.php -FROM scratch AS php-7_4_x64_zts -COPY --from=php-7_4_x64_zts-build /engine_7_4_x64_zts.h / - +COPY symbols.txt . +RUN php process.php linux +FROM scratch AS php-7-4-x64-nts-linux +COPY --from=php-7-4-x64-nts-linux-build /engine-7-4-x64-nts-linux.h / +COPY --from=php-7-4-x64-nts-linux-build /constants-7-4-x64-nts-linux.php / FROM scratch -COPY --from=php-8_1_x64_zts /engine_8_1_x64_zts.h / -COPY --from=php-8_1_x64_nts /engine_8_1_x64_nts.h / -COPY --from=php-8_0_x64_zts /engine_8_0_x64_zts.h / -COPY --from=php-8_0_x64_nts /engine_8_0_x64_nts.h / -COPY --from=php-7_4_x64_zts /engine_7_4_x64_zts.h / -COPY --from=php-7_4_x64_nts /engine_7_4_x64_nts.h / +COPY --from=php-8-1-x64-zts-linux /* / +COPY --from=php-8-1-x64-nts-linux /* / +COPY --from=php-8-0-x64-zts-linux /* / +COPY --from=php-8-0-x64-nts-linux /* / +COPY --from=php-7-4-x64-zts-linux /* / +COPY --from=php-7-4-x64-nts-linux /* / diff --git a/include/Dockerfile.php b/include/Dockerfile.php new file mode 100644 index 0000000..725327a --- /dev/null +++ b/include/Dockerfile.php @@ -0,0 +1,27 @@ + srcml.deb +RUN apt install -y ./srcml.deb +COPY process.php . +COPY symbols.txt . +RUN php process.php $os +FROM scratch AS php-$major-$minor-$arch-$threadSafety-$os +COPY --from=php-$major-$minor-$arch-$threadSafety-$os-build /engine-$major-$minor-$arch-$threadSafety-$os.h / +COPY --from=php-$major-$minor-$arch-$threadSafety-$os-build /constants-$major-$minor-$arch-$threadSafety-$os.php / + + +DOCKERFILE; + $bottom .= "COPY --from=php-$major-$minor-$arch-$threadSafety-$os /* /\n"; + } + +echo "$top$bottom"; \ No newline at end of file diff --git a/include/README b/include/README deleted file mode 100644 index c3f92bd..0000000 --- a/include/README +++ /dev/null @@ -1,2 +0,0 @@ -To regenerate headers, run: docker buildx build . -o . -To generate headers without checking (useful for getting a copy of the header file to identify any errors), comment out the last line of process.php \ No newline at end of file diff --git a/include/README.md b/include/README.md new file mode 100644 index 0000000..5f40b9b --- /dev/null +++ b/include/README.md @@ -0,0 +1,25 @@ +To regenerate the dockerfile, run `php Dockerfile.php > Dockerfile` +To regenerate headers, run: `docker buildx build . -o .` +To generate headers without checking (useful for getting a copy of the header file to identify any errors), comment out the last line of process.php + +Symbols syntax: +- `x`: export symbol x +- `#x`: export definition x +- `//...`: Comment + +Modifiers (after a symbol): +- `zts` / `nts`: Only import symbol on thread-safe/non-thread-safe +- `x.y` / `<=x.y` / `>=x.y` / `=x.y` / `!=x.y`: Only import symbol on a given PHP version + +To add a new symbol: +- Check what PHP versions it's defined in and if it's in an `#ifdef` (specifically `ZTS`) and add modifiers as appropriate +- Add to bottom of symbols.txt *unless* required by another symbol (in which case list it above) +- Regenerate headers and ensure all builds pass +- Commit updated headers + +To add a new PHP version: +- Add to Dockerfile.php +- Regenerate dockerfile +- Regenerate headers +- Add modifier for any removed symbols to exclude them +- Add modifier for any newly required symbols (ex. members of common classes) \ No newline at end of file diff --git a/include/constants-7-4-x64-nts-linux.php b/include/constants-7-4-x64-nts-linux.php new file mode 100644 index 0000000..d017473 --- /dev/null +++ b/include/constants-7-4-x64-nts-linux.php @@ -0,0 +1,428 @@ +=", "<", ">", "=", "!="] as $comparator) { + if(substr($modifier, 0, strlen($comparator)) !== $comparator) continue; + $versionToCompare = substr($modifier, strlen($comparator)); + if(!preg_match("/^[0-9]+\\.[0-9]+$/", $versionToCompare)) continue; // Try next comparator + if(version_compare(PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION, $versionToCompare, $comparator)) { + continue 2; // Success, go to next modifier + } else { + continue 3; // Fail, go to next line + } + } + if($modifier === "zts") { + if(ZEND_THREAD_SAFE) { + continue; // Success, go to next modifier + } else { + continue 2; // Fail, go to next line + } + } + if($modifier === "nts") { + if(!ZEND_THREAD_SAFE) { + continue; // Success, go to next modifier + } else { + continue 2; // Fail, go to next line + } + } + throw new RuntimeException("Could not parse modifier $modifier"); + } + if($isDefine) { + $definesDef .= "_$name = $name,\n\t"; + } else { + $symbolsToExport[] = $name; + } +} + $cCode = escapeshellarg(<<loadXML(`echo $cCode|cpp $(php-config --includes) -P -C -D"__attribute__(ARGS)=" - |srcml --language C`); // Remove all comments @@ -28,7 +89,6 @@ $parent->removeChild($comment); } -$version = PHP_MAJOR_VERSION."_" . PHP_MINOR_VERSION . "_" . (PHP_INT_SIZE === 8 ? "x64" : "x32") . "_" . (ZEND_THREAD_SAFE ? "zts" : "nts"); $symbols = []; @@ -112,26 +172,72 @@ $symbols[$children[1]->textContent] = $func->textContent; } } +$defines = []; +/** + * @var DOMElement $enum + */ +foreach(iterator_to_array($xml->getElementsByTagName("enum")) as $enum) { + // + + /** + * @var list $children + */ + $children = array_values(array_filter(iterator_to_array($enum->childNodes), fn(DOMNode $dn): bool => $dn instanceof DOMElement)); + if($children[0]->localName === "name") { + $name = $children[0]->textContent; + $symbols[$name] = "@@ENUM@@"; + $children = $enum->getElementsByTagName("decl"); + $defines[$name] = []; + $lastValue = 0; + foreach($children as $decl) { + $children = array_values(array_filter(iterator_to_array($decl->childNodes), fn(DOMNode $dn): bool => $dn instanceof DOMElement)); + if(count($children) === 2) { + + // Let's just run C as PHP. What could go wrong? + $defines[$name][$children[0]->textContent] = $lastValue = eval("\$x " . str_replace("1U", "1", $children[1]->textContent) . "; return \$x;"); + } elseif(count($children) === 1) { + $defines[$name][$children[0]->textContent] = ++$lastValue; + } + } + } +} // Remove duplicate newlines $symbols = array_map(fn(string $s) => preg_replace('/^[ \t]*[\r\n]+/m', '', $s), $symbols); -$fname = __DIR__ . "/engine_$version.h"; -$f = fopen($fname, "w"); +$headerFile = fopen(__DIR__ . "/engine-$version.h", "w"); +$constantsFile = fopen(__DIR__ . "/constants-$version.php", "w"); + +fwrite($headerFile, "#define FFI_SCOPE \"ZEngine\"\n#define FFI_LIB \"".($isWindows ? "php" . PHP_MAJOR_VERSION . ".dll" : "")."\"\n"); +fwrite($constantsFile, " $value) { + if ($symbolName === "__defines") $key = substr($key, 1); + fwrite($constantsFile, "\tpublic const $key = " . var_export($value, true) . ";\n"); + } + fwrite($constantsFile, "}\n"); + } else { + fwrite($headerFile, "$symbol\n"); } - fwrite($f, "$symbol\n"); } -fclose($f); +fclose($headerFile); +fclose($constantsFile); -FFI::cdef(file_get_contents($fname)); +FFI::cdef(file_get_contents(__DIR__ . "/engine-$version.h")); //echo json_encode($symbols, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT); // Turn into headers again: srcml out.xml | grep . diff --git a/include/symbols.txt b/include/symbols.txt new file mode 100644 index 0000000..da26bba --- /dev/null +++ b/include/symbols.txt @@ -0,0 +1,537 @@ +zend_long +zend_ulong +zend_off_t +zend_bool +zend_uchar +zend_type +ZEND_RESULT_CODE +zend_object_handlers +zend_class_entry +zend_function +zend_execute_data +zval +zend_refcounted +zend_string +zend_array +zend_object +zend_resource +zend_reference +zend_ast_ref +zend_ast +compare_func_t +swap_func_t +sort_func_t +dtor_func_t +copy_ctor_func_t +zend_value +_zval_struct +zend_refcounted_h +_zend_refcounted +_zend_string +Bucket +HashTable +_zend_array +HashPosition +HashTableIterator +_zend_object +_zend_resource +zend_property_info_list +zend_property_info_source_list +_zend_reference +_zend_ast_ref +zend_ast_kind +zend_ast_attr +_zend_ast +zend_ast_list +zend_ast_zval +zend_ast_decl +zend_ast_process_t +zend_intptr_t +zend_uintptr_t +zend_arena +_zend_arena +zend_op_array +zend_op +znode_op +znode +zend_ast_znode +zend_declarables +zend_file_context +zend_lexer_ident_ref =8.0 +zend_parser_stack_elem +user_opcode_handler_t +_zend_op +zend_brk_cont_element +zend_label +zend_try_catch_element +zend_live_range +zend_oparray_context +zend_property_info +zend_class_constant +zend_internal_arg_info +zend_arg_info +zend_internal_function_info +_zend_op_array +zif_handler +zend_internal_function +_zend_function +_zend_execute_data +zend_closure +std_object_handlers +zend_object_read_property_t +zend_object_read_dimension_t +zend_object_write_property_t +zend_object_write_dimension_t +zend_object_get_property_ptr_ptr_t +zend_object_has_property_t +zend_object_has_dimension_t +zend_object_unset_property_t +zend_object_unset_dimension_t +zend_object_get_properties_t +zend_object_get_debug_info_t +zend_prop_purpose +zend_object_get_properties_for_t +zend_object_get_method_t +zend_object_get_constructor_t +zend_object_dtor_obj_t +zend_object_free_obj_t +zend_object_clone_obj_t +zend_object_get_class_name_t +zend_object_compare_t +zend_object_cast_t +zend_object_count_elements_t +zend_object_get_closure_t +zend_object_get_gc_t +zend_object_do_operation_t +zend_object_get_t <=7.4 +zend_object_set_t <=7.4 +zend_object_call_method_t <=7.4 +zend_object_compare_zvals_t <=7.4 +_zend_object_handlers +zend_llist_element +llist_dtor_func_t +llist_compare_func_t +llist_apply_with_args_func_t +llist_apply_with_arg_func_t +llist_apply_func_t +zend_llist +zend_llist_position +zend_encoding +zend_stack +zend_vm_stack +zend_ini_entry +zend_php_scanner_event +_zend_vm_stack +zend_function_entry +zend_fcall_info +zend_fcall_info_cache +zend_object_iterator +zend_object_iterator_funcs +_zend_object_iterator +zend_class_iterator_funcs +_zend_serialize_data +_zend_unserialize_data +zend_serialize_data +zend_unserialize_data +zend_class_name +zend_trait_method_reference +zend_trait_precedence +zend_trait_alias +zend_class_mutable_data >=8.1 +zend_inheritance_cache_entry >=8.1 +_zend_class_entry +zend_error_handling_t +zend_error_handling +zend_objects_store +_zend_ini_entry +zend_module_entry +zend_module_dep +zend_result >=8.0 +ts_rsrc_id zts +_zend_module_entry +_zend_module_dep +zend_gc_status +zend_get_gc_buffer >=8.0 +_zend_compiler_globals +zend_compiler_globals +jmp_buf +fpu_control_t <=7.4 +zend_fiber >=8.1 +zend_fiber_context >=8.1 +zend_error_info >=8.1 +_zend_executor_globals +zend_executor_globals +executor_globals nts +compiler_globals nts +tsrm_get_ls_cache zts +compiler_globals_offset zts +executor_globals_offset zts +FILE +zend_stream_fsizer_t +zend_stream_reader_t +zend_stream_closer_t +zend_stream_type +zend_stream +zend_file_handle +zend_ptr_stack +zend_encoding_filter +zend_lex_state +zend_heredoc_label +zend_ast_process +module_registry +zend_hash_del +zend_hash_find +zend_hash_add_or_update +zend_set_user_opcode_handler +zend_get_user_opcode_handler +zend_do_inheritance_ex +zend_objects_new +zend_object_std_init +object_properties_init +zend_save_lexical_state +zend_restore_lexical_state +zend_prepare_string_for_scanning +zend_lex_tstring +zendparse +zend_ast_destroy +zend_ast_create_list_0 +zend_ast_list_add +zend_ast_create_zval_ex +zend_ast_create_0 +zend_ast_create_1 +zend_ast_create_2 +zend_ast_create_3 +zend_ast_create_4 +zend_ast_create_decl +zend_register_module_ex +zend_startup_module_ex +#ZEND_AST_SPECIAL_SHIFT +#ZEND_AST_IS_LIST_SHIFT +#ZEND_AST_NUM_CHILDREN_SHIFT +__defines +_zend_ast_kind +#MODULE_PERSISTENT +#MODULE_TEMPORARY +#MODULE_DEP_REQUIRED +#MODULE_DEP_CONFLICTS +#MODULE_DEP_OPTIONAL +#IS_UNDEF +#IS_NULL +#IS_FALSE +#IS_TRUE +#IS_LONG +#IS_DOUBLE +#IS_STRING +#IS_ARRAY +#IS_OBJECT +#IS_RESOURCE +#IS_REFERENCE +#IS_CONSTANT_AST +#IS_CALLABLE +#IS_ITERABLE +#IS_VOID +#IS_STATIC >=8.0 +#IS_MIXED >=8.0 +#IS_NEVER >=8.1 +#IS_INDIRECT +#IS_PTR +#IS_ALIAS_PTR >=8.0 +#_IS_ERROR +#_IS_BOOL +#_IS_NUMBER +#Z_TYPE_FLAGS_MASK +#ZEND_COMPILE_EXTENDED_STMT +#ZEND_COMPILE_EXTENDED_FCALL +#ZEND_COMPILE_EXTENDED_INFO +#ZEND_COMPILE_HANDLE_OP_ARRAY +#ZEND_COMPILE_IGNORE_INTERNAL_FUNCTIONS +#ZEND_COMPILE_IGNORE_INTERNAL_CLASSES +#ZEND_COMPILE_DELAYED_BINDING +#ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION +#ZEND_COMPILE_NO_PERSISTENT_CONSTANT_SUBSTITUTION +#ZEND_COMPILE_IGNORE_USER_FUNCTIONS +#ZEND_COMPILE_GUARDS +#ZEND_COMPILE_NO_BUILTINS +#ZEND_COMPILE_WITH_FILE_CACHE +#ZEND_COMPILE_IGNORE_OTHER_FILES +#ZEND_COMPILE_WITHOUT_EXECUTION +#ZEND_COMPILE_PRELOAD +#ZEND_COMPILE_NO_JUMPTABLES +#ZEND_COMPILE_PRELOAD_IN_CHILD +#ZEND_COMPILE_DEFAULT +#ZEND_COMPILE_DEFAULT_FOR_EVAL +#OBJ_BUCKET_INVALID +#ZEND_NOP +#ZEND_ADD +#ZEND_SUB +#ZEND_MUL +#ZEND_DIV +#ZEND_MOD +#ZEND_SL +#ZEND_SR +#ZEND_CONCAT +#ZEND_BW_OR +#ZEND_BW_AND +#ZEND_BW_XOR +#ZEND_POW +#ZEND_BW_NOT +#ZEND_BOOL_NOT +#ZEND_BOOL_XOR +#ZEND_IS_IDENTICAL +#ZEND_IS_NOT_IDENTICAL +#ZEND_IS_EQUAL +#ZEND_IS_NOT_EQUAL +#ZEND_IS_SMALLER +#ZEND_IS_SMALLER_OR_EQUAL +#ZEND_ASSIGN +#ZEND_ASSIGN_DIM +#ZEND_ASSIGN_OBJ +#ZEND_ASSIGN_STATIC_PROP +#ZEND_ASSIGN_OP +#ZEND_ASSIGN_DIM_OP +#ZEND_ASSIGN_OBJ_OP +#ZEND_ASSIGN_STATIC_PROP_OP +#ZEND_ASSIGN_REF +#ZEND_QM_ASSIGN +#ZEND_ASSIGN_OBJ_REF +#ZEND_ASSIGN_STATIC_PROP_REF +#ZEND_PRE_INC +#ZEND_PRE_DEC +#ZEND_POST_INC +#ZEND_POST_DEC +#ZEND_PRE_INC_STATIC_PROP +#ZEND_PRE_DEC_STATIC_PROP +#ZEND_POST_INC_STATIC_PROP +#ZEND_POST_DEC_STATIC_PROP +#ZEND_JMP +#ZEND_JMPZ +#ZEND_JMPNZ +#ZEND_JMPZNZ +#ZEND_JMPZ_EX +#ZEND_JMPNZ_EX +#ZEND_CASE +#ZEND_CHECK_VAR +#ZEND_SEND_VAR_NO_REF_EX +#ZEND_CAST +#ZEND_BOOL +#ZEND_FAST_CONCAT +#ZEND_ROPE_INIT +#ZEND_ROPE_ADD +#ZEND_ROPE_END +#ZEND_BEGIN_SILENCE +#ZEND_END_SILENCE +#ZEND_INIT_FCALL_BY_NAME +#ZEND_DO_FCALL +#ZEND_INIT_FCALL +#ZEND_RETURN +#ZEND_RECV +#ZEND_RECV_INIT +#ZEND_SEND_VAL +#ZEND_SEND_VAR_EX +#ZEND_SEND_REF +#ZEND_NEW +#ZEND_INIT_NS_FCALL_BY_NAME +#ZEND_FREE +#ZEND_INIT_ARRAY +#ZEND_ADD_ARRAY_ELEMENT +#ZEND_INCLUDE_OR_EVAL +#ZEND_UNSET_VAR +#ZEND_UNSET_DIM +#ZEND_UNSET_OBJ +#ZEND_FE_RESET_R +#ZEND_FE_FETCH_R +#ZEND_EXIT +#ZEND_FETCH_R +#ZEND_FETCH_DIM_R +#ZEND_FETCH_OBJ_R +#ZEND_FETCH_W +#ZEND_FETCH_DIM_W +#ZEND_FETCH_OBJ_W +#ZEND_FETCH_RW +#ZEND_FETCH_DIM_RW +#ZEND_FETCH_OBJ_RW +#ZEND_FETCH_IS +#ZEND_FETCH_DIM_IS +#ZEND_FETCH_OBJ_IS +#ZEND_FETCH_FUNC_ARG +#ZEND_FETCH_DIM_FUNC_ARG +#ZEND_FETCH_OBJ_FUNC_ARG +#ZEND_FETCH_UNSET +#ZEND_FETCH_DIM_UNSET +#ZEND_FETCH_OBJ_UNSET +#ZEND_FETCH_LIST_R +#ZEND_FETCH_CONSTANT +#ZEND_CHECK_FUNC_ARG +#ZEND_EXT_STMT +#ZEND_EXT_FCALL_BEGIN +#ZEND_EXT_FCALL_END +#ZEND_EXT_NOP +#ZEND_TICKS +#ZEND_SEND_VAR_NO_REF +#ZEND_CATCH +#ZEND_THROW +#ZEND_FETCH_CLASS +#ZEND_CLONE +#ZEND_RETURN_BY_REF +#ZEND_INIT_METHOD_CALL +#ZEND_INIT_STATIC_METHOD_CALL +#ZEND_ISSET_ISEMPTY_VAR +#ZEND_ISSET_ISEMPTY_DIM_OBJ +#ZEND_SEND_VAL_EX +#ZEND_SEND_VAR +#ZEND_INIT_USER_CALL +#ZEND_SEND_ARRAY +#ZEND_SEND_USER +#ZEND_STRLEN +#ZEND_DEFINED +#ZEND_TYPE_CHECK +#ZEND_VERIFY_RETURN_TYPE +#ZEND_FE_RESET_RW +#ZEND_FE_FETCH_RW +#ZEND_FE_FREE +#ZEND_INIT_DYNAMIC_CALL +#ZEND_DO_ICALL +#ZEND_DO_UCALL +#ZEND_DO_FCALL_BY_NAME +#ZEND_PRE_INC_OBJ +#ZEND_PRE_DEC_OBJ +#ZEND_POST_INC_OBJ +#ZEND_POST_DEC_OBJ +#ZEND_ECHO +#ZEND_OP_DATA +#ZEND_INSTANCEOF +#ZEND_GENERATOR_CREATE +#ZEND_MAKE_REF +#ZEND_DECLARE_FUNCTION +#ZEND_DECLARE_LAMBDA_FUNCTION +#ZEND_DECLARE_CONST +#ZEND_DECLARE_CLASS +#ZEND_DECLARE_CLASS_DELAYED +#ZEND_DECLARE_ANON_CLASS +#ZEND_ADD_ARRAY_UNPACK +#ZEND_ISSET_ISEMPTY_PROP_OBJ +#ZEND_HANDLE_EXCEPTION +#ZEND_USER_OPCODE +#ZEND_ASSERT_CHECK +#ZEND_JMP_SET +#ZEND_UNSET_CV +#ZEND_ISSET_ISEMPTY_CV +#ZEND_FETCH_LIST_W +#ZEND_SEPARATE +#ZEND_FETCH_CLASS_NAME +#ZEND_CALL_TRAMPOLINE +#ZEND_DISCARD_EXCEPTION +#ZEND_YIELD +#ZEND_GENERATOR_RETURN +#ZEND_FAST_CALL +#ZEND_FAST_RET +#ZEND_RECV_VARIADIC +#ZEND_SEND_UNPACK +#ZEND_YIELD_FROM +#ZEND_COPY_TMP +#ZEND_BIND_GLOBAL +#ZEND_COALESCE +#ZEND_SPACESHIP +#ZEND_FUNC_NUM_ARGS +#ZEND_FUNC_GET_ARGS +#ZEND_FETCH_STATIC_PROP_R +#ZEND_FETCH_STATIC_PROP_W +#ZEND_FETCH_STATIC_PROP_RW +#ZEND_FETCH_STATIC_PROP_IS +#ZEND_FETCH_STATIC_PROP_FUNC_ARG +#ZEND_FETCH_STATIC_PROP_UNSET +#ZEND_UNSET_STATIC_PROP +#ZEND_ISSET_ISEMPTY_STATIC_PROP +#ZEND_FETCH_CLASS_CONSTANT +#ZEND_BIND_LEXICAL +#ZEND_BIND_STATIC +#ZEND_FETCH_THIS +#ZEND_SEND_FUNC_ARG +#ZEND_ISSET_ISEMPTY_THIS +#ZEND_SWITCH_LONG +#ZEND_SWITCH_STRING +#ZEND_IN_ARRAY +#ZEND_COUNT +#ZEND_GET_CLASS +#ZEND_GET_CALLED_CLASS +#ZEND_GET_TYPE +#ZEND_ARRAY_KEY_EXISTS +#ZEND_MATCH >=8.0 +#ZEND_CASE_STRICT >=8.0 +#ZEND_MATCH_ERROR >=8.0 +#ZEND_JMP_NULL >=8.0 +#ZEND_CHECK_UNDEF_ARGS >=8.1 +#ZEND_FETCH_GLOBALS >=8.1 +#ZEND_VERIFY_NEVER_TYPE >=8.1 +#ZEND_CALLABLE_CONVERT >=8.1 +#HASH_UPDATE +#HASH_ADD +#HASH_UPDATE_INDIRECT +#HASH_ADD_NEW +#HASH_ADD_NEXT +#IS_UNUSED +#IS_CONST +#IS_TMP_VAR +#IS_VAR +#IS_CV +#ZEND_ACC_PUBLIC +#ZEND_ACC_PROTECTED +#ZEND_ACC_PRIVATE +#ZEND_ACC_CHANGED +#ZEND_ACC_STATIC +#ZEND_ACC_FINAL +#ZEND_ACC_ABSTRACT +#ZEND_ACC_EXPLICIT_ABSTRACT_CLASS +#ZEND_ACC_IMMUTABLE +#ZEND_ACC_HAS_TYPE_HINTS +#ZEND_ACC_TOP_LEVEL +#ZEND_ACC_PRELOADED +#ZEND_ACC_INTERFACE +#ZEND_ACC_TRAIT +#ZEND_ACC_ANON_CLASS +#ZEND_ACC_LINKED +#ZEND_ACC_IMPLICIT_ABSTRACT_CLASS +#ZEND_ACC_USE_GUARDS +#ZEND_ACC_CONSTANTS_UPDATED +#ZEND_HAS_STATIC_IN_METHODS +#ZEND_ACC_REUSE_GET_ITERATOR +#ZEND_ACC_RESOLVED_PARENT +#ZEND_ACC_RESOLVED_INTERFACES +#ZEND_ACC_UNRESOLVED_VARIANCE +#ZEND_ACC_DEPRECATED +#ZEND_ACC_RETURN_REFERENCE +#ZEND_ACC_HAS_RETURN_TYPE +#ZEND_ACC_VARIADIC +#ZEND_ACC_HAS_FINALLY_BLOCK +#ZEND_ACC_EARLY_BINDING +#ZEND_ACC_CALL_VIA_TRAMPOLINE +#ZEND_ACC_NEVER_CACHE +#ZEND_ACC_CLOSURE +#ZEND_ACC_FAKE_CLOSURE +#ZEND_ACC_HEAP_RT_CACHE +#ZEND_ACC_USER_ARG_INFO +#ZEND_ACC_GENERATOR +#ZEND_ACC_DONE_PASS_TWO +#ZEND_ACC_ARENA_ALLOCATED +#ZEND_ACC_TRAIT_CLONE +#ZEND_ACC_CTOR +#ZEND_ACC_STRICT_TYPES +#ZEND_ACC_PPP_MASK +#ZEND_INTERNAL_FUNCTION +#ZEND_USER_FUNCTION +#ZEND_EVAL_CODE +#ZEND_INTERNAL_CLASS +#ZEND_USER_CLASS +#ZEND_USER_OPCODE_CONTINUE +#ZEND_USER_OPCODE_RETURN +#ZEND_USER_OPCODE_DISPATCH +#ZEND_USER_OPCODE_ENTER +#ZEND_USER_OPCODE_LEAVE +#ZEND_USER_OPCODE_DISPATCH_TO +#ZEND_MM_ALIGNMENT +#GC_COLLECTABLE <=7.4 +#GC_NOT_COLLECTABLE >=8.0 +#GC_PROTECTED +#GC_IMMUTABLE +#GC_PERSISTENT +#GC_PERSISTENT_LOCAL \ No newline at end of file diff --git a/include/symbols_7_4_x64_nts.txt b/include/symbols_7_4_x64_nts.txt deleted file mode 100644 index c77bed9..0000000 --- a/include/symbols_7_4_x64_nts.txt +++ /dev/null @@ -1,194 +0,0 @@ -zend_long -zend_ulong -zend_off_t -zend_bool -zend_uchar -zend_type -ZEND_RESULT_CODE -zend_object_handlers -zend_class_entry -zend_function -zend_execute_data -zval -zend_refcounted -zend_string -zend_array -zend_object -zend_resource -zend_reference -zend_ast_ref -zend_ast -compare_func_t -swap_func_t -sort_func_t -dtor_func_t -copy_ctor_func_t -zend_value -_zval_struct -zend_refcounted_h -_zend_refcounted -_zend_string -Bucket -HashTable -_zend_array -HashPosition -HashTableIterator -_zend_object -_zend_resource -zend_property_info_list -zend_property_info_source_list -_zend_reference -_zend_ast_ref -zend_ast_kind -zend_ast_attr -_zend_ast -zend_ast_list -zend_ast_zval -zend_ast_decl -zend_ast_process_t -zend_intptr_t -zend_uintptr_t -zend_arena -_zend_arena -zend_op_array -zend_op -znode_op -znode -zend_ast_znode -zend_declarables -zend_file_context -zend_parser_stack_elem -user_opcode_handler_t -_zend_op -zend_brk_cont_element -zend_label -zend_try_catch_element -zend_live_range -zend_oparray_context -zend_property_info -zend_class_constant -zend_internal_arg_info -zend_arg_info -zend_internal_function_info -_zend_op_array -zif_handler -zend_internal_function -_zend_function -_zend_execute_data -zend_closure -std_object_handlers -zend_object_read_property_t -zend_object_read_dimension_t -zend_object_write_property_t -zend_object_write_dimension_t -zend_object_get_property_ptr_ptr_t -zend_object_has_property_t -zend_object_has_dimension_t -zend_object_unset_property_t -zend_object_unset_dimension_t -zend_object_get_properties_t -zend_object_get_debug_info_t -zend_prop_purpose -zend_object_get_properties_for_t -zend_object_get_method_t -zend_object_get_constructor_t -zend_object_dtor_obj_t -zend_object_free_obj_t -zend_object_clone_obj_t -zend_object_get_class_name_t -zend_object_compare_t -zend_object_cast_t -zend_object_count_elements_t -zend_object_get_closure_t -zend_object_get_gc_t -zend_object_do_operation_t -zend_object_get_t -zend_object_set_t -zend_object_call_method_t -zend_object_compare_zvals_t -_zend_object_handlers -zend_llist_element -llist_dtor_func_t -llist_compare_func_t -llist_apply_with_args_func_t -llist_apply_with_arg_func_t -llist_apply_func_t -zend_llist -zend_llist_position -zend_encoding -zend_stack -zend_vm_stack -zend_ini_entry -zend_php_scanner_event -_zend_vm_stack -zend_function_entry -zend_fcall_info -zend_fcall_info_cache -zend_object_iterator -zend_object_iterator_funcs -_zend_object_iterator -zend_class_iterator_funcs -_zend_serialize_data -_zend_unserialize_data -zend_serialize_data -zend_unserialize_data -zend_class_name -zend_trait_method_reference -zend_trait_precedence -zend_trait_alias -_zend_class_entry -zend_error_handling_t -zend_error_handling -zend_objects_store -_zend_ini_entry -zend_module_entry -zend_module_dep -_zend_module_entry -_zend_module_dep -zend_gc_status -_zend_compiler_globals -jmp_buf -fpu_control_t -_zend_executor_globals -zend_executor_globals -executor_globals -compiler_globals -FILE -zend_stream_fsizer_t -zend_stream_reader_t -zend_stream_closer_t -zend_stream_type -zend_stream -zend_file_handle -zend_ptr_stack -zend_encoding_filter -zend_lex_state -zend_heredoc_label -zend_ast_process -module_registry -zend_hash_del -zend_hash_find -zend_hash_add_or_update -zend_set_user_opcode_handler -zend_get_user_opcode_handler -zend_do_inheritance_ex -zend_objects_new -zend_object_std_init -object_properties_init -zend_save_lexical_state -zend_restore_lexical_state -zend_prepare_string_for_scanning -zend_lex_tstring -zendparse -zend_ast_destroy -zend_ast_create_list_0 -zend_ast_list_add -zend_ast_create_zval_ex -zend_ast_create_0 -zend_ast_create_1 -zend_ast_create_2 -zend_ast_create_3 -zend_ast_create_4 -zend_ast_create_decl -zend_register_module_ex -zend_startup_module_ex diff --git a/include/symbols_7_4_x64_zts.txt b/include/symbols_7_4_x64_zts.txt deleted file mode 100644 index 1c2b311..0000000 --- a/include/symbols_7_4_x64_zts.txt +++ /dev/null @@ -1,193 +0,0 @@ -zend_long -zend_ulong -zend_off_t -zend_bool -zend_uchar -zend_type -ZEND_RESULT_CODE -zend_object_handlers -zend_class_entry -zend_function -zend_execute_data -zval -zend_refcounted -zend_string -zend_array -zend_object -zend_resource -zend_reference -zend_ast_ref -zend_ast -compare_func_t -swap_func_t -sort_func_t -dtor_func_t -copy_ctor_func_t -zend_value -_zval_struct -zend_refcounted_h -_zend_refcounted -_zend_string -Bucket -HashTable -_zend_array -HashPosition -HashTableIterator -_zend_object -_zend_resource -zend_property_info_list -zend_property_info_source_list -_zend_reference -_zend_ast_ref -zend_ast_kind -zend_ast_attr -_zend_ast -zend_ast_list -zend_ast_zval -zend_ast_decl -zend_ast_process_t -zend_intptr_t -zend_uintptr_t -zend_arena -_zend_arena -zend_op_array -zend_op -znode_op -znode -zend_ast_znode -zend_declarables -zend_file_context -zend_parser_stack_elem -user_opcode_handler_t -_zend_op -zend_brk_cont_element -zend_label -zend_try_catch_element -zend_live_range -zend_oparray_context -zend_property_info -zend_class_constant -zend_internal_arg_info -zend_arg_info -zend_internal_function_info -_zend_op_array -zif_handler -zend_internal_function -_zend_function -_zend_execute_data -zend_closure -std_object_handlers -zend_object_read_property_t -zend_object_read_dimension_t -zend_object_write_property_t -zend_object_write_dimension_t -zend_object_get_property_ptr_ptr_t -zend_object_has_property_t -zend_object_has_dimension_t -zend_object_unset_property_t -zend_object_unset_dimension_t -zend_object_get_properties_t -zend_object_get_debug_info_t -zend_prop_purpose -zend_object_get_properties_for_t -zend_object_get_method_t -zend_object_get_constructor_t -zend_object_dtor_obj_t -zend_object_free_obj_t -zend_object_clone_obj_t -zend_object_get_class_name_t -zend_object_compare_t -zend_object_cast_t -zend_object_count_elements_t -zend_object_get_closure_t -zend_object_get_gc_t -zend_object_do_operation_t -zend_object_get_t -zend_object_set_t -zend_object_call_method_t -zend_object_compare_zvals_t -_zend_object_handlers -zend_llist_element -llist_dtor_func_t -llist_compare_func_t -llist_apply_with_args_func_t -llist_apply_with_arg_func_t -llist_apply_func_t -zend_llist -zend_llist_position -zend_encoding -zend_stack -zend_vm_stack -zend_ini_entry -zend_php_scanner_event -_zend_vm_stack -zend_function_entry -zend_fcall_info -zend_fcall_info_cache -zend_object_iterator -zend_object_iterator_funcs -_zend_object_iterator -zend_class_iterator_funcs -_zend_serialize_data -_zend_unserialize_data -zend_serialize_data -zend_unserialize_data -zend_class_name -zend_trait_method_reference -zend_trait_precedence -zend_trait_alias -_zend_class_entry -zend_error_handling_t -zend_error_handling -zend_objects_store -_zend_ini_entry -zend_module_entry -zend_module_dep -ts_rsrc_id -_zend_module_entry -_zend_module_dep -zend_gc_status -_zend_compiler_globals -jmp_buf -fpu_control_t -_zend_executor_globals -zend_executor_globals -FILE -zend_stream_fsizer_t -zend_stream_reader_t -zend_stream_closer_t -zend_stream_type -zend_stream -zend_file_handle -zend_ptr_stack -zend_encoding_filter -zend_lex_state -zend_heredoc_label -zend_ast_process -module_registry -zend_hash_del -zend_hash_find -zend_hash_add_or_update -zend_set_user_opcode_handler -zend_get_user_opcode_handler -zend_do_inheritance_ex -zend_objects_new -zend_object_std_init -object_properties_init -zend_save_lexical_state -zend_restore_lexical_state -zend_prepare_string_for_scanning -zend_lex_tstring -zendparse -zend_ast_destroy -zend_ast_create_list_0 -zend_ast_list_add -zend_ast_create_zval_ex -zend_ast_create_0 -zend_ast_create_1 -zend_ast_create_2 -zend_ast_create_3 -zend_ast_create_4 -zend_ast_create_decl -zend_register_module_ex -zend_startup_module_ex diff --git a/include/symbols_8_0_x64_nts.txt b/include/symbols_8_0_x64_nts.txt deleted file mode 100644 index 4329e99..0000000 --- a/include/symbols_8_0_x64_nts.txt +++ /dev/null @@ -1,192 +0,0 @@ -zend_long -zend_ulong -zend_off_t -zend_bool -zend_uchar -zend_type -ZEND_RESULT_CODE -zend_object_handlers -zend_class_entry -zend_function -zend_execute_data -zval -zend_refcounted -zend_string -zend_array -zend_object -zend_resource -zend_reference -zend_ast_ref -zend_ast -compare_func_t -swap_func_t -sort_func_t -dtor_func_t -copy_ctor_func_t -zend_value -_zval_struct -zend_refcounted_h -_zend_refcounted -_zend_string -Bucket -HashTable -_zend_array -HashPosition -HashTableIterator -_zend_object -_zend_resource -zend_property_info_list -zend_property_info_source_list -_zend_reference -_zend_ast_ref -zend_ast_kind -zend_ast_attr -_zend_ast -zend_ast_list -zend_ast_zval -zend_ast_decl -zend_ast_process_t -zend_intptr_t -zend_uintptr_t -zend_arena -_zend_arena -zend_op_array -zend_op -znode_op -znode -zend_ast_znode -zend_declarables -zend_file_context -zend_lexer_ident_ref -zend_parser_stack_elem -user_opcode_handler_t -_zend_op -zend_brk_cont_element -zend_label -zend_try_catch_element -zend_live_range -zend_oparray_context -zend_property_info -zend_class_constant -zend_internal_arg_info -zend_arg_info -zend_internal_function_info -_zend_op_array -zif_handler -zend_internal_function -_zend_function -_zend_execute_data -zend_closure -std_object_handlers -zend_object_read_property_t -zend_object_read_dimension_t -zend_object_write_property_t -zend_object_write_dimension_t -zend_object_get_property_ptr_ptr_t -zend_object_has_property_t -zend_object_has_dimension_t -zend_object_unset_property_t -zend_object_unset_dimension_t -zend_object_get_properties_t -zend_object_get_debug_info_t -zend_prop_purpose -zend_object_get_properties_for_t -zend_object_get_method_t -zend_object_get_constructor_t -zend_object_dtor_obj_t -zend_object_free_obj_t -zend_object_clone_obj_t -zend_object_get_class_name_t -zend_object_compare_t -zend_object_cast_t -zend_object_count_elements_t -zend_object_get_closure_t -zend_object_get_gc_t -zend_object_do_operation_t -_zend_object_handlers -zend_llist_element -llist_dtor_func_t -llist_compare_func_t -llist_apply_with_args_func_t -llist_apply_with_arg_func_t -llist_apply_func_t -zend_llist -zend_llist_position -zend_encoding -zend_stack -zend_vm_stack -zend_ini_entry -zend_php_scanner_event -_zend_vm_stack -zend_function_entry -zend_fcall_info -zend_fcall_info_cache -zend_object_iterator -zend_object_iterator_funcs -_zend_object_iterator -zend_class_iterator_funcs -_zend_serialize_data -_zend_unserialize_data -zend_serialize_data -zend_unserialize_data -zend_class_name -zend_trait_method_reference -zend_trait_precedence -zend_trait_alias -_zend_class_entry -zend_error_handling_t -zend_error_handling -zend_objects_store -_zend_ini_entry -zend_module_entry -zend_module_dep -zend_result -_zend_module_entry -_zend_module_dep -zend_gc_status -zend_get_gc_buffer -_zend_compiler_globals -jmp_buf -_zend_executor_globals -zend_executor_globals -executor_globals -compiler_globals -FILE -zend_stream_fsizer_t -zend_stream_reader_t -zend_stream_closer_t -zend_stream_type -zend_stream -zend_file_handle -zend_ptr_stack -zend_encoding_filter -zend_lex_state -zend_heredoc_label -zend_ast_process -module_registry -zend_hash_del -zend_hash_find -zend_hash_add_or_update -zend_set_user_opcode_handler -zend_get_user_opcode_handler -zend_do_inheritance_ex -zend_objects_new -zend_object_std_init -object_properties_init -zend_save_lexical_state -zend_restore_lexical_state -zend_prepare_string_for_scanning -zend_lex_tstring -zendparse -zend_ast_destroy -zend_ast_create_list_0 -zend_ast_list_add -zend_ast_create_zval_ex -zend_ast_create_0 -zend_ast_create_1 -zend_ast_create_2 -zend_ast_create_3 -zend_ast_create_4 -zend_ast_create_decl -zend_register_module_ex -zend_startup_module_ex diff --git a/include/symbols_8_0_x64_zts.txt b/include/symbols_8_0_x64_zts.txt deleted file mode 100644 index 79e7d7d..0000000 --- a/include/symbols_8_0_x64_zts.txt +++ /dev/null @@ -1,191 +0,0 @@ -zend_long -zend_ulong -zend_off_t -zend_bool -zend_uchar -zend_type -ZEND_RESULT_CODE -zend_object_handlers -zend_class_entry -zend_function -zend_execute_data -zval -zend_refcounted -zend_string -zend_array -zend_object -zend_resource -zend_reference -zend_ast_ref -zend_ast -compare_func_t -swap_func_t -sort_func_t -dtor_func_t -copy_ctor_func_t -zend_value -_zval_struct -zend_refcounted_h -_zend_refcounted -_zend_string -Bucket -HashTable -_zend_array -HashPosition -HashTableIterator -_zend_object -_zend_resource -zend_property_info_list -zend_property_info_source_list -_zend_reference -_zend_ast_ref -zend_ast_kind -zend_ast_attr -_zend_ast -zend_ast_list -zend_ast_zval -zend_ast_decl -zend_ast_process_t -zend_intptr_t -zend_uintptr_t -zend_arena -_zend_arena -zend_op_array -zend_op -znode_op -znode -zend_ast_znode -zend_declarables -zend_file_context -zend_lexer_ident_ref -zend_parser_stack_elem -user_opcode_handler_t -_zend_op -zend_brk_cont_element -zend_label -zend_try_catch_element -zend_live_range -zend_oparray_context -zend_property_info -zend_class_constant -zend_internal_arg_info -zend_arg_info -zend_internal_function_info -_zend_op_array -zif_handler -zend_internal_function -_zend_function -_zend_execute_data -zend_closure -std_object_handlers -zend_object_read_property_t -zend_object_read_dimension_t -zend_object_write_property_t -zend_object_write_dimension_t -zend_object_get_property_ptr_ptr_t -zend_object_has_property_t -zend_object_has_dimension_t -zend_object_unset_property_t -zend_object_unset_dimension_t -zend_object_get_properties_t -zend_object_get_debug_info_t -zend_prop_purpose -zend_object_get_properties_for_t -zend_object_get_method_t -zend_object_get_constructor_t -zend_object_dtor_obj_t -zend_object_free_obj_t -zend_object_clone_obj_t -zend_object_get_class_name_t -zend_object_compare_t -zend_object_cast_t -zend_object_count_elements_t -zend_object_get_closure_t -zend_object_get_gc_t -zend_object_do_operation_t -_zend_object_handlers -zend_llist_element -llist_dtor_func_t -llist_compare_func_t -llist_apply_with_args_func_t -llist_apply_with_arg_func_t -llist_apply_func_t -zend_llist -zend_llist_position -zend_encoding -zend_stack -zend_vm_stack -zend_ini_entry -zend_php_scanner_event -_zend_vm_stack -zend_function_entry -zend_fcall_info -zend_fcall_info_cache -zend_object_iterator -zend_object_iterator_funcs -_zend_object_iterator -zend_class_iterator_funcs -_zend_serialize_data -_zend_unserialize_data -zend_serialize_data -zend_unserialize_data -zend_class_name -zend_trait_method_reference -zend_trait_precedence -zend_trait_alias -_zend_class_entry -zend_error_handling_t -zend_error_handling -zend_objects_store -_zend_ini_entry -zend_module_entry -zend_module_dep -zend_result -ts_rsrc_id -_zend_module_entry -_zend_module_dep -zend_gc_status -zend_get_gc_buffer -_zend_compiler_globals -jmp_buf -_zend_executor_globals -zend_executor_globals -FILE -zend_stream_fsizer_t -zend_stream_reader_t -zend_stream_closer_t -zend_stream_type -zend_stream -zend_file_handle -zend_ptr_stack -zend_encoding_filter -zend_lex_state -zend_heredoc_label -zend_ast_process -module_registry -zend_hash_del -zend_hash_find -zend_hash_add_or_update -zend_set_user_opcode_handler -zend_get_user_opcode_handler -zend_do_inheritance_ex -zend_objects_new -zend_object_std_init -object_properties_init -zend_save_lexical_state -zend_restore_lexical_state -zend_prepare_string_for_scanning -zend_lex_tstring -zendparse -zend_ast_destroy -zend_ast_create_list_0 -zend_ast_list_add -zend_ast_create_zval_ex -zend_ast_create_0 -zend_ast_create_1 -zend_ast_create_2 -zend_ast_create_3 -zend_ast_create_4 -zend_ast_create_decl -zend_register_module_ex -zend_startup_module_ex diff --git a/include/symbols_8_1_x64_nts.txt b/include/symbols_8_1_x64_nts.txt deleted file mode 100644 index 36a0a96..0000000 --- a/include/symbols_8_1_x64_nts.txt +++ /dev/null @@ -1,196 +0,0 @@ -zend_long -zend_ulong -zend_off_t -zend_bool -zend_uchar -zend_type -ZEND_RESULT_CODE -zend_object_handlers -zend_class_entry -zend_function -zend_execute_data -zval -zend_refcounted -zend_string -zend_array -zend_object -zend_resource -zend_reference -zend_ast_ref -zend_ast -compare_func_t -swap_func_t -sort_func_t -dtor_func_t -copy_ctor_func_t -zend_value -_zval_struct -zend_refcounted_h -_zend_refcounted -_zend_string -Bucket -HashTable -_zend_array -HashPosition -HashTableIterator -_zend_object -_zend_resource -zend_property_info_list -zend_property_info_source_list -_zend_reference -_zend_ast_ref -zend_ast_kind -zend_ast_attr -_zend_ast -zend_ast_list -zend_ast_zval -zend_ast_decl -zend_ast_process_t -zend_intptr_t -zend_uintptr_t -zend_arena -_zend_arena -zend_op_array -zend_op -znode_op -znode -zend_ast_znode -zend_declarables -zend_file_context -zend_parser_stack_elem -user_opcode_handler_t -_zend_op -zend_brk_cont_element -zend_label -zend_try_catch_element -zend_live_range -zend_oparray_context -zend_property_info -zend_class_constant -zend_internal_arg_info -zend_arg_info -zend_internal_function_info -_zend_op_array -zif_handler -zend_internal_function -_zend_function -_zend_execute_data -zend_closure -std_object_handlers -zend_object_read_property_t -zend_object_read_dimension_t -zend_object_write_property_t -zend_object_write_dimension_t -zend_object_get_property_ptr_ptr_t -zend_object_has_property_t -zend_object_has_dimension_t -zend_object_unset_property_t -zend_object_unset_dimension_t -zend_object_get_properties_t -zend_object_get_debug_info_t -zend_prop_purpose -zend_object_get_properties_for_t -zend_object_get_method_t -zend_object_get_constructor_t -zend_object_dtor_obj_t -zend_object_free_obj_t -zend_object_clone_obj_t -zend_object_get_class_name_t -zend_object_compare_t -zend_object_cast_t -zend_object_count_elements_t -zend_object_get_closure_t -zend_object_get_gc_t -zend_object_do_operation_t -_zend_object_handlers -zend_llist_element -llist_dtor_func_t -llist_compare_func_t -llist_apply_with_args_func_t -llist_apply_with_arg_func_t -llist_apply_func_t -zend_llist -zend_llist_position -zend_encoding -zend_stack -zend_vm_stack -zend_ini_entry -zend_php_scanner_event -_zend_vm_stack -zend_function_entry -zend_fcall_info -zend_fcall_info_cache -zend_object_iterator -zend_object_iterator_funcs -_zend_object_iterator -zend_class_iterator_funcs -_zend_serialize_data -_zend_unserialize_data -zend_serialize_data -zend_unserialize_data -zend_class_name -zend_trait_method_reference -zend_trait_precedence -zend_trait_alias -zend_class_mutable_data -zend_inheritance_cache_entry -_zend_class_entry -zend_error_handling_t -zend_error_handling -zend_objects_store -_zend_ini_entry -zend_module_entry -zend_module_dep -zend_result -_zend_module_entry -_zend_module_dep -zend_gc_status -zend_get_gc_buffer -_zend_compiler_globals -jmp_buf -zend_fiber -zend_fiber_context -zend_error_info -_zend_executor_globals -zend_executor_globals -executor_globals -compiler_globals -FILE -zend_stream_fsizer_t -zend_stream_reader_t -zend_stream_closer_t -zend_stream_type -zend_stream -zend_file_handle -zend_ptr_stack -zend_encoding_filter -zend_lex_state -zend_heredoc_label -zend_ast_process -module_registry -zend_hash_del -zend_hash_find -zend_hash_add_or_update -zend_set_user_opcode_handler -zend_get_user_opcode_handler -zend_do_inheritance_ex -zend_objects_new -zend_object_std_init -object_properties_init -zend_save_lexical_state -zend_restore_lexical_state -zend_prepare_string_for_scanning -zend_lex_tstring -zendparse -zend_ast_destroy -zend_ast_create_list_0 -zend_ast_list_add -zend_ast_create_zval_ex -zend_ast_create_0 -zend_ast_create_1 -zend_ast_create_2 -zend_ast_create_3 -zend_ast_create_4 -zend_ast_create_decl -zend_register_module_ex -zend_startup_module_ex diff --git a/include/symbols_8_1_x64_zts.txt b/include/symbols_8_1_x64_zts.txt deleted file mode 100644 index 62ae0d2..0000000 --- a/include/symbols_8_1_x64_zts.txt +++ /dev/null @@ -1,195 +0,0 @@ -zend_long -zend_ulong -zend_off_t -zend_bool -zend_uchar -zend_type -ZEND_RESULT_CODE -zend_object_handlers -zend_class_entry -zend_function -zend_execute_data -zval -zend_refcounted -zend_string -zend_array -zend_object -zend_resource -zend_reference -zend_ast_ref -zend_ast -compare_func_t -swap_func_t -sort_func_t -dtor_func_t -copy_ctor_func_t -zend_value -_zval_struct -zend_refcounted_h -_zend_refcounted -_zend_string -Bucket -HashTable -_zend_array -HashPosition -HashTableIterator -_zend_object -_zend_resource -zend_property_info_list -zend_property_info_source_list -_zend_reference -_zend_ast_ref -zend_ast_kind -zend_ast_attr -_zend_ast -zend_ast_list -zend_ast_zval -zend_ast_decl -zend_ast_process_t -zend_intptr_t -zend_uintptr_t -zend_arena -_zend_arena -zend_op_array -zend_op -znode_op -znode -zend_ast_znode -zend_declarables -zend_file_context -zend_parser_stack_elem -user_opcode_handler_t -_zend_op -zend_brk_cont_element -zend_label -zend_try_catch_element -zend_live_range -zend_oparray_context -zend_property_info -zend_class_constant -zend_internal_arg_info -zend_arg_info -zend_internal_function_info -_zend_op_array -zif_handler -zend_internal_function -_zend_function -_zend_execute_data -zend_closure -std_object_handlers -zend_object_read_property_t -zend_object_read_dimension_t -zend_object_write_property_t -zend_object_write_dimension_t -zend_object_get_property_ptr_ptr_t -zend_object_has_property_t -zend_object_has_dimension_t -zend_object_unset_property_t -zend_object_unset_dimension_t -zend_object_get_properties_t -zend_object_get_debug_info_t -zend_prop_purpose -zend_object_get_properties_for_t -zend_object_get_method_t -zend_object_get_constructor_t -zend_object_dtor_obj_t -zend_object_free_obj_t -zend_object_clone_obj_t -zend_object_get_class_name_t -zend_object_compare_t -zend_object_cast_t -zend_object_count_elements_t -zend_object_get_closure_t -zend_object_get_gc_t -zend_object_do_operation_t -_zend_object_handlers -zend_llist_element -llist_dtor_func_t -llist_compare_func_t -llist_apply_with_args_func_t -llist_apply_with_arg_func_t -llist_apply_func_t -zend_llist -zend_llist_position -zend_encoding -zend_stack -zend_vm_stack -zend_ini_entry -zend_php_scanner_event -_zend_vm_stack -zend_function_entry -zend_fcall_info -zend_fcall_info_cache -zend_object_iterator -zend_object_iterator_funcs -_zend_object_iterator -zend_class_iterator_funcs -_zend_serialize_data -_zend_unserialize_data -zend_serialize_data -zend_unserialize_data -zend_class_name -zend_trait_method_reference -zend_trait_precedence -zend_trait_alias -zend_class_mutable_data -zend_inheritance_cache_entry -_zend_class_entry -zend_error_handling_t -zend_error_handling -zend_objects_store -_zend_ini_entry -zend_module_entry -zend_module_dep -zend_result -ts_rsrc_id -_zend_module_entry -_zend_module_dep -zend_gc_status -zend_get_gc_buffer -_zend_compiler_globals -jmp_buf -zend_fiber -zend_fiber_context -zend_error_info -_zend_executor_globals -zend_executor_globals -FILE -zend_stream_fsizer_t -zend_stream_reader_t -zend_stream_closer_t -zend_stream_type -zend_stream -zend_file_handle -zend_ptr_stack -zend_encoding_filter -zend_lex_state -zend_heredoc_label -zend_ast_process -module_registry -zend_hash_del -zend_hash_find -zend_hash_add_or_update -zend_set_user_opcode_handler -zend_get_user_opcode_handler -zend_do_inheritance_ex -zend_objects_new -zend_object_std_init -object_properties_init -zend_save_lexical_state -zend_restore_lexical_state -zend_prepare_string_for_scanning -zend_lex_tstring -zendparse -zend_ast_destroy -zend_ast_create_list_0 -zend_ast_list_add -zend_ast_create_zval_ex -zend_ast_create_0 -zend_ast_create_1 -zend_ast_create_2 -zend_ast_create_3 -zend_ast_create_4 -zend_ast_create_decl -zend_register_module_ex -zend_startup_module_ex diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 20436f1..98e63f5 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -11,7 +11,9 @@ + bootstrap="./tests/bootstrap.php" + convertDeprecationsToExceptions="true" + > ./src/ diff --git a/src/AbstractSyntaxTree/NodeFactory.php b/src/AbstractSyntaxTree/NodeFactory.php index 2007fe7..36d0f52 100644 --- a/src/AbstractSyntaxTree/NodeFactory.php +++ b/src/AbstractSyntaxTree/NodeFactory.php @@ -13,6 +13,7 @@ namespace ZEngine\AbstractSyntaxTree; use FFI\CData; +use ZEngine\Constants\_zend_ast_kind; use ZEngine\Core; /** @@ -32,7 +33,8 @@ public static function fromCData(CData $node): NodeInterface $kind = $node->kind; switch (true) { // There are special node types ZVAL, CONSTANT, ZNODE - case $kind === NodeKind::AST_ZVAL: +// case $kind === NodeKind::AST_ZVAL: + case $kind === _zend_ast_kind::ZEND_AST_ZVAL()->value : $node = Core::cast('zend_ast_zval *', $node); return ValueNode::fromCData($node); case $kind === NodeKind::AST_CONSTANT: diff --git a/src/AbstractSyntaxTree/NodeKind.php b/src/AbstractSyntaxTree/NodeKind.php index 9d7c841..f560488 100644 --- a/src/AbstractSyntaxTree/NodeKind.php +++ b/src/AbstractSyntaxTree/NodeKind.php @@ -12,6 +12,9 @@ namespace ZEngine\AbstractSyntaxTree; +use ZEngine\Constants\_zend_ast_kind; +use ZEngine\Constants\Defines; + /** * Declares possible AST nodes kind * @@ -19,130 +22,130 @@ */ class NodeKind { - private const AST_SPECIAL_SHIFT = 6; - private const AST_IS_LIST_SHIFT = 7; - private const AST_NUM_CHILDREN_SHIFT = 8; + private const AST_SPECIAL_SHIFT = Defines::ZEND_AST_SPECIAL_SHIFT; + private const AST_IS_LIST_SHIFT = Defines::ZEND_AST_IS_LIST_SHIFT; + private const AST_NUM_CHILDREN_SHIFT = Defines::ZEND_AST_NUM_CHILDREN_SHIFT; - public const AST_ZVAL = 1 << self::AST_SPECIAL_SHIFT; - public const AST_CONSTANT = self::AST_ZVAL + 1; - public const AST_ZNODE = self::AST_ZVAL + 2; + public const AST_ZVAL =_zend_ast_kind::ZEND_AST_ZVAL; + public const AST_CONSTANT =_zend_ast_kind::ZEND_AST_CONSTANT; + public const AST_ZNODE =_zend_ast_kind::ZEND_AST_ZNODE; /* declaration nodes */ - public const AST_FUNC_DECL = self::AST_ZVAL + 3; - public const AST_CLOSURE = self::AST_ZVAL + 4; - public const AST_METHOD = self::AST_ZVAL + 5; - public const AST_CLASS = self::AST_ZVAL + 6; - public const AST_ARROW_FUNC = self::AST_ZVAL + 7; + public const AST_FUNC_DECL =_zend_ast_kind::ZEND_AST_FUNC_DECL; + public const AST_CLOSURE =_zend_ast_kind::ZEND_AST_CLOSURE; + public const AST_METHOD =_zend_ast_kind::ZEND_AST_METHOD; + public const AST_CLASS =_zend_ast_kind::ZEND_AST_CLASS; + public const AST_ARROW_FUNC =_zend_ast_kind::ZEND_AST_ARROW_FUNC; /* list nodes */ - public const AST_ARG_LIST = 1 << self::AST_IS_LIST_SHIFT; - public const AST_ARRAY = self::AST_ARG_LIST + 1; - public const AST_ENCAPS_LIST = self::AST_ARG_LIST + 2; - public const AST_EXPR_LIST = self::AST_ARG_LIST + 3; - public const AST_STMT_LIST = self::AST_ARG_LIST + 4; - public const AST_IF = self::AST_ARG_LIST + 5; - public const AST_SWITCH_LIST = self::AST_ARG_LIST + 6; - public const AST_CATCH_LIST = self::AST_ARG_LIST + 7; - public const AST_PARAM_LIST = self::AST_ARG_LIST + 8; - public const AST_CLOSURE_USES = self::AST_ARG_LIST + 9; - public const AST_PROP_DECL = self::AST_ARG_LIST + 10; - public const AST_CONST_DECL = self::AST_ARG_LIST + 11; - public const AST_CLASS_CONST_DECL = self::AST_ARG_LIST + 12; - public const AST_NAME_LIST = self::AST_ARG_LIST + 13; - public const AST_TRAIT_ADAPTATIONS = self::AST_ARG_LIST + 14; - public const AST_USE = self::AST_ARG_LIST + 15; + public const AST_ARG_LIST =_zend_ast_kind::ZEND_AST_ARG_LIST; + public const AST_ARRAY =_zend_ast_kind::ZEND_AST_ARRAY; + public const AST_ENCAPS_LIST =_zend_ast_kind::ZEND_AST_ENCAPS_LIST; + public const AST_EXPR_LIST =_zend_ast_kind::ZEND_AST_EXPR_LIST; + public const AST_STMT_LIST =_zend_ast_kind::ZEND_AST_STMT_LIST; + public const AST_IF =_zend_ast_kind::ZEND_AST_IF; + public const AST_SWITCH_LIST =_zend_ast_kind::ZEND_AST_SWITCH_LIST; + public const AST_CATCH_LIST =_zend_ast_kind::ZEND_AST_CATCH_LIST; + public const AST_PARAM_LIST =_zend_ast_kind::ZEND_AST_PARAM_LIST; + public const AST_CLOSURE_USES =_zend_ast_kind::ZEND_AST_CLOSURE_USES; + public const AST_PROP_DECL =_zend_ast_kind::ZEND_AST_PROP_DECL; + public const AST_CONST_DECL =_zend_ast_kind::ZEND_AST_CONST_DECL; + public const AST_CLASS_CONST_DECL =_zend_ast_kind::ZEND_AST_CLASS_CONST_DECL; + public const AST_NAME_LIST =_zend_ast_kind::ZEND_AST_NAME_LIST; + public const AST_TRAIT_ADAPTATIONS =_zend_ast_kind::ZEND_AST_TRAIT_ADAPTATIONS; + public const AST_USE =_zend_ast_kind::ZEND_AST_USE; /* 0 child nodes */ - public const AST_MAGIC_CONST = 0 << self::AST_NUM_CHILDREN_SHIFT; - public const AST_TYPE = self::AST_MAGIC_CONST + 1; - public const AST_CONSTANT_CLASS = self::AST_MAGIC_CONST + 2; + public const AST_MAGIC_CONST =_zend_ast_kind::ZEND_AST_MAGIC_CONST; + public const AST_TYPE =_zend_ast_kind::ZEND_AST_TYPE; + public const AST_CONSTANT_CLASS =_zend_ast_kind::ZEND_AST_CONSTANT_CLASS; /* 1 child node */ - public const AST_VAR = 1 << self::AST_NUM_CHILDREN_SHIFT; - public const AST_CONST = self::AST_VAR + 1; - public const AST_UNPACK = self::AST_VAR + 2; - public const AST_UNARY_PLUS = self::AST_VAR + 3; - public const AST_UNARY_MINUS = self::AST_VAR + 4; - public const AST_CAST = self::AST_VAR + 5; - public const AST_EMPTY = self::AST_VAR + 6; - public const AST_ISSET = self::AST_VAR + 7; - public const AST_SILENCE = self::AST_VAR + 8; - public const AST_SHELL_EXEC = self::AST_VAR + 9; - public const AST_CLONE = self::AST_VAR + 10; - public const AST_EXIT = self::AST_VAR + 11; - public const AST_PRINT = self::AST_VAR + 12; - public const AST_INCLUDE_OR_EVAL = self::AST_VAR + 13; - public const AST_UNARY_OP = self::AST_VAR + 14; - public const AST_PRE_INC = self::AST_VAR + 15; - public const AST_PRE_DEC = self::AST_VAR + 16; - public const AST_POST_INC = self::AST_VAR + 17; - public const AST_POST_DEC = self::AST_VAR + 18; - public const AST_YIELD_FROM = self::AST_VAR + 19; - public const AST_CLASS_NAME = self::AST_VAR + 20; - - public const AST_GLOBAL = self::AST_VAR + 21; - public const AST_UNSET = self::AST_VAR + 22; - public const AST_RETURN = self::AST_VAR + 23; - public const AST_LABEL = self::AST_VAR + 24; - public const AST_REF = self::AST_VAR + 25; - public const AST_HALT_COMPILER = self::AST_VAR + 26; - public const AST_ECHO = self::AST_VAR + 27; - public const AST_THROW = self::AST_VAR + 28; - public const AST_GOTO = self::AST_VAR + 29; - public const AST_BREAK = self::AST_VAR + 30; - public const AST_CONTINUE = self::AST_VAR + 31; + public const AST_VAR =_zend_ast_kind::ZEND_AST_VAR; + public const AST_CONST =_zend_ast_kind::ZEND_AST_CONST; + public const AST_UNPACK =_zend_ast_kind::ZEND_AST_UNPACK; + public const AST_UNARY_PLUS =_zend_ast_kind::ZEND_AST_UNARY_PLUS; + public const AST_UNARY_MINUS =_zend_ast_kind::ZEND_AST_UNARY_MINUS; + public const AST_CAST =_zend_ast_kind::ZEND_AST_CAST; + public const AST_EMPTY =_zend_ast_kind::ZEND_AST_EMPTY; + public const AST_ISSET =_zend_ast_kind::ZEND_AST_ISSET; + public const AST_SILENCE =_zend_ast_kind::ZEND_AST_SILENCE; + public const AST_SHELL_EXEC =_zend_ast_kind::ZEND_AST_SHELL_EXEC; + public const AST_CLONE =_zend_ast_kind::ZEND_AST_CLONE; + public const AST_EXIT =_zend_ast_kind::ZEND_AST_EXIT; + public const AST_PRINT =_zend_ast_kind::ZEND_AST_PRINT; + public const AST_INCLUDE_OR_EVAL =_zend_ast_kind::ZEND_AST_INCLUDE_OR_EVAL; + public const AST_UNARY_OP =_zend_ast_kind::ZEND_AST_UNARY_OP; + public const AST_PRE_INC =_zend_ast_kind::ZEND_AST_PRE_INC; + public const AST_PRE_DEC =_zend_ast_kind::ZEND_AST_PRE_DEC; + public const AST_POST_INC =_zend_ast_kind::ZEND_AST_POST_INC; + public const AST_POST_DEC =_zend_ast_kind::ZEND_AST_POST_DEC; + public const AST_YIELD_FROM =_zend_ast_kind::ZEND_AST_YIELD_FROM; + public const AST_CLASS_NAME =_zend_ast_kind::ZEND_AST_CLASS_NAME; + + public const AST_GLOBAL =_zend_ast_kind::ZEND_AST_GLOBAL; + public const AST_UNSET =_zend_ast_kind::ZEND_AST_UNSET; + public const AST_RETURN =_zend_ast_kind::ZEND_AST_RETURN; + public const AST_LABEL =_zend_ast_kind::ZEND_AST_LABEL; + public const AST_REF =_zend_ast_kind::ZEND_AST_REF; + public const AST_HALT_COMPILER =_zend_ast_kind::ZEND_AST_HALT_COMPILER; + public const AST_ECHO =_zend_ast_kind::ZEND_AST_ECHO; + public const AST_THROW =_zend_ast_kind::ZEND_AST_THROW; + public const AST_GOTO =_zend_ast_kind::ZEND_AST_GOTO; + public const AST_BREAK =_zend_ast_kind::ZEND_AST_BREAK; + public const AST_CONTINUE =_zend_ast_kind::ZEND_AST_CONTINUE; /* 2 child nodes */ - public const AST_DIM = 2 << self::AST_NUM_CHILDREN_SHIFT; - public const AST_PROP = self::AST_DIM + 1; - public const AST_STATIC_PROP = self::AST_DIM + 2; - public const AST_CALL = self::AST_DIM + 3; - public const AST_CLASS_CONST = self::AST_DIM + 4; - public const AST_ASSIGN = self::AST_DIM + 5; - public const AST_ASSIGN_REF = self::AST_DIM + 6; - public const AST_ASSIGN_OP = self::AST_DIM + 7; - public const AST_BINARY_OP = self::AST_DIM + 8; - public const AST_GREATER = self::AST_DIM + 9; - public const AST_GREATER_EQUAL = self::AST_DIM + 10; - public const AST_AND = self::AST_DIM + 11; - public const AST_OR = self::AST_DIM + 12; - public const AST_ARRAY_ELEM = self::AST_DIM + 13; - public const AST_NEW = self::AST_DIM + 14; - public const AST_INSTANCEOF = self::AST_DIM + 15; - public const AST_YIELD = self::AST_DIM + 16; - public const AST_COALESCE = self::AST_DIM + 17; - public const AST_ASSIGN_COALESCE = self::AST_DIM + 18; - - public const AST_STATIC = self::AST_DIM + 19; - public const AST_WHILE = self::AST_DIM + 20; - public const AST_DO_WHILE = self::AST_DIM + 21; - public const AST_IF_ELEM = self::AST_DIM + 22; - public const AST_SWITCH = self::AST_DIM + 23; - public const AST_SWITCH_CASE = self::AST_DIM + 24; - public const AST_DECLARE = self::AST_DIM + 25; - public const AST_USE_TRAIT = self::AST_DIM + 26; - public const AST_TRAIT_PRECEDENCE = self::AST_DIM + 27; - public const AST_METHOD_REFERENCE = self::AST_DIM + 28; - public const AST_NAMESPACE = self::AST_DIM + 29; - public const AST_USE_ELEM = self::AST_DIM + 30; - public const AST_TRAIT_ALIAS = self::AST_DIM + 31; - public const AST_GROUP_USE = self::AST_DIM + 32; - public const AST_PROP_GROUP = self::AST_DIM + 33; + public const AST_DIM =_zend_ast_kind::ZEND_AST_DIM; + public const AST_PROP =_zend_ast_kind::ZEND_AST_PROP; + public const AST_STATIC_PROP =_zend_ast_kind::ZEND_AST_STATIC_PROP; + public const AST_CALL =_zend_ast_kind::ZEND_AST_CALL; + public const AST_CLASS_CONST =_zend_ast_kind::ZEND_AST_CLASS_CONST; + public const AST_ASSIGN =_zend_ast_kind::ZEND_AST_ASSIGN; + public const AST_ASSIGN_REF =_zend_ast_kind::ZEND_AST_ASSIGN_REF; + public const AST_ASSIGN_OP =_zend_ast_kind::ZEND_AST_ASSIGN_OP; + public const AST_BINARY_OP =_zend_ast_kind::ZEND_AST_BINARY_OP; + public const AST_GREATER =_zend_ast_kind::ZEND_AST_GREATER; + public const AST_GREATER_EQUAL =_zend_ast_kind::ZEND_AST_GREATER_EQUAL; + public const AST_AND =_zend_ast_kind::ZEND_AST_AND; + public const AST_OR =_zend_ast_kind::ZEND_AST_OR; + public const AST_ARRAY_ELEM =_zend_ast_kind::ZEND_AST_ARRAY_ELEM; + public const AST_NEW =_zend_ast_kind::ZEND_AST_NEW; + public const AST_INSTANCEOF =_zend_ast_kind::ZEND_AST_INSTANCEOF; + public const AST_YIELD =_zend_ast_kind::ZEND_AST_YIELD; + public const AST_COALESCE =_zend_ast_kind::ZEND_AST_COALESCE; + public const AST_ASSIGN_COALESCE =_zend_ast_kind::ZEND_AST_ASSIGN_COALESCE; + + public const AST_STATIC =_zend_ast_kind::ZEND_AST_STATIC; + public const AST_WHILE =_zend_ast_kind::ZEND_AST_WHILE; + public const AST_DO_WHILE =_zend_ast_kind::ZEND_AST_DO_WHILE; + public const AST_IF_ELEM =_zend_ast_kind::ZEND_AST_IF_ELEM; + public const AST_SWITCH =_zend_ast_kind::ZEND_AST_SWITCH; + public const AST_SWITCH_CASE =_zend_ast_kind::ZEND_AST_SWITCH_CASE; + public const AST_DECLARE =_zend_ast_kind::ZEND_AST_DECLARE; + public const AST_USE_TRAIT =_zend_ast_kind::ZEND_AST_USE_TRAIT; + public const AST_TRAIT_PRECEDENCE =_zend_ast_kind::ZEND_AST_TRAIT_PRECEDENCE; + public const AST_METHOD_REFERENCE =_zend_ast_kind::ZEND_AST_METHOD_REFERENCE; + public const AST_NAMESPACE =_zend_ast_kind::ZEND_AST_NAMESPACE; + public const AST_USE_ELEM =_zend_ast_kind::ZEND_AST_USE_ELEM; + public const AST_TRAIT_ALIAS =_zend_ast_kind::ZEND_AST_TRAIT_ALIAS; + public const AST_GROUP_USE =_zend_ast_kind::ZEND_AST_GROUP_USE; + public const AST_PROP_GROUP =_zend_ast_kind::ZEND_AST_PROP_GROUP; /* 3 child nodes */ - public const AST_METHOD_CALL = 3 << self::AST_NUM_CHILDREN_SHIFT; - public const AST_STATIC_CALL = self::AST_METHOD_CALL + 1; - public const AST_CONDITIONAL = self::AST_METHOD_CALL + 2; + public const AST_METHOD_CALL =_zend_ast_kind::ZEND_AST_METHOD_CALL; + public const AST_STATIC_CALL =_zend_ast_kind::ZEND_AST_STATIC_CALL; + public const AST_CONDITIONAL =_zend_ast_kind::ZEND_AST_CONDITIONAL; - public const AST_TRY = self::AST_METHOD_CALL + 3; - public const AST_CATCH = self::AST_METHOD_CALL + 4; - public const AST_PARAM = self::AST_METHOD_CALL + 5; - public const AST_PROP_ELEM = self::AST_METHOD_CALL + 6; - public const AST_CONST_ELEM = self::AST_METHOD_CALL + 7; + public const AST_TRY =_zend_ast_kind::ZEND_AST_TRY; + public const AST_CATCH =_zend_ast_kind::ZEND_AST_CATCH; + public const AST_PARAM =_zend_ast_kind::ZEND_AST_PARAM; + public const AST_PROP_ELEM =_zend_ast_kind::ZEND_AST_PROP_ELEM; + public const AST_CONST_ELEM =_zend_ast_kind::ZEND_AST_CONST_ELEM; /* 4 child nodes */ - public const AST_FOR = 4 << self::AST_NUM_CHILDREN_SHIFT; - public const AST_FOREACH = self::AST_FOR + 1; + public const AST_FOR =_zend_ast_kind::ZEND_AST_FOR; + public const AST_FOREACH =_zend_ast_kind::ZEND_AST_FOREACH; /** * Cache of constant names (reversed) diff --git a/src/Core.php b/src/Core.php index 13e495b..f4a6698 100644 --- a/src/Core.php +++ b/src/Core.php @@ -18,7 +18,7 @@ use FFI\CType; use RecursiveDirectoryIterator; use RecursiveIteratorIterator; -use ZEngine\Macro\DefinitionLoader; +use ZEngine\Constants\Defines; use ZEngine\System\Compiler; use ZEngine\System\Executor; use ZEngine\System\Hook\AstProcessHook; @@ -36,172 +36,172 @@ class Core /* ============ | | | | */ /* | | | | */ /* Visibility flags (public < protected < private); | | | | */ - public const ZEND_ACC_PUBLIC = (1 << 0); /* | | X | X | X */ - public const ZEND_ACC_PROTECTED = (1 << 1); /* | | X | X | X */ - public const ZEND_ACC_PRIVATE = (1 << 2); /* | | X | X | X */ + public const ZEND_ACC_PUBLIC = Defines::ZEND_ACC_PUBLIC; /* | | X | X | X */ + public const ZEND_ACC_PROTECTED = Defines::ZEND_ACC_PROTECTED; /* | | X | X | X */ + public const ZEND_ACC_PRIVATE = Defines::ZEND_ACC_PRIVATE; /* | | X | X | X */ /* | | | | */ /* Property or method overrides private one | | | | */ - public const ZEND_ACC_CHANGED = (1 << 3); /* | | X | X | */ + public const ZEND_ACC_CHANGED = Defines::ZEND_ACC_CHANGED; /* | | X | X | */ /* | | | | */ /* Static method or property | | | | */ - public const ZEND_ACC_STATIC = (1 << 4); /* | | X | X | */ + public const ZEND_ACC_STATIC = Defines::ZEND_ACC_STATIC; /* | | X | X | */ /* | | | | */ /* Final class or method | | | | */ - public const ZEND_ACC_FINAL = (1 << 5); /* | X | X | | */ + public const ZEND_ACC_FINAL = Defines::ZEND_ACC_FINAL; /* | X | X | | */ /* | | | | */ /* Abstract method | | | | */ - public const ZEND_ACC_ABSTRACT = (1 << 6); /* | X | X | | */ - public const ZEND_ACC_EXPLICIT_ABSTRACT_CLASS = (1 << 6); /* | X | | | */ + public const ZEND_ACC_ABSTRACT = Defines::ZEND_ACC_ABSTRACT; /* | X | X | | */ + public const ZEND_ACC_EXPLICIT_ABSTRACT_CLASS = Defines::ZEND_ACC_EXPLICIT_ABSTRACT_CLASS; /* | X | | | */ /* | | | | */ /* Immutable op_array and class_entries | | | | */ /* (implemented only for lazy loading of op_arrays); | | | | */ - public const ZEND_ACC_IMMUTABLE = (1 << 7); /* | X | X | | */ + public const ZEND_ACC_IMMUTABLE = Defines::ZEND_ACC_IMMUTABLE; /* | X | X | | */ /* | | | | */ /* Function has typed arguments / class has typed props | | | | */ - public const ZEND_ACC_HAS_TYPE_HINTS = (1 << 8); /* | X | X | | */ + public const ZEND_ACC_HAS_TYPE_HINTS = Defines::ZEND_ACC_HAS_TYPE_HINTS; /* | X | X | | */ /* | | | | */ /* Top-level class or function declaration | | | | */ - public const ZEND_ACC_TOP_LEVEL = (1 << 9); /* | X | X | | */ + public const ZEND_ACC_TOP_LEVEL = Defines::ZEND_ACC_TOP_LEVEL; /* | X | X | | */ /* | | | | */ /* op_array or class is preloaded | | | | */ - public const ZEND_ACC_PRELOADED = (1 << 10); /* | X | X | | */ + public const ZEND_ACC_PRELOADED = Defines::ZEND_ACC_PRELOADED; /* | X | X | | */ /* | | | | */ /* Class Flags (unused: 16...); | | | | */ /* =========== | | | | */ /* | | | | */ /* Special class types | | | | */ - public const ZEND_ACC_INTERFACE = (1 << 0); /* | X | | | */ - public const ZEND_ACC_TRAIT = (1 << 1); /* | X | | | */ - public const ZEND_ACC_ANON_CLASS = (1 << 2); /* | X | | | */ + public const ZEND_ACC_INTERFACE = Defines::ZEND_ACC_INTERFACE; /* | X | | | */ + public const ZEND_ACC_TRAIT = Defines::ZEND_ACC_TRAIT; /* | X | | | */ + public const ZEND_ACC_ANON_CLASS = Defines::ZEND_ACC_ANON_CLASS; /* | X | | | */ /* | | | | */ /* Class linked with parent, interfaces and traits | | | | */ - public const ZEND_ACC_LINKED = (1 << 3); /* | X | | | */ + public const ZEND_ACC_LINKED = Defines::ZEND_ACC_LINKED; /* | X | | | */ /* | | | | */ /* Class is abstract, since it is set by any | | | | */ /* abstract method | | | | */ - public const ZEND_ACC_IMPLICIT_ABSTRACT_CLASS = (1 << 4); /* | X | | | */ + public const ZEND_ACC_IMPLICIT_ABSTRACT_CLASS = Defines::ZEND_ACC_IMPLICIT_ABSTRACT_CLASS; /* | X | | | */ /* | | | | */ /* Class has magic methods __get/__set/__unset/ | | | | */ /* __isset that use guards | | | | */ - public const ZEND_ACC_USE_GUARDS = (1 << 11); /* | X | | | */ + public const ZEND_ACC_USE_GUARDS = Defines::ZEND_ACC_USE_GUARDS; /* | X | | | */ /* | | | | */ /* Class constants updated | | | | */ - public const ZEND_ACC_CONSTANTS_UPDATED = (1 << 12); /* | X | | | */ + public const ZEND_ACC_CONSTANTS_UPDATED = Defines::ZEND_ACC_CONSTANTS_UPDATED; /* | X | | | */ /* | | | | */ /* Class extends another class | | | | */ - public const ZEND_ACC_INHERITED = (1 << 13); /* | X | | | */ +// public const ZEND_ACC_INHERITED = Defines::ZEND_ACC_INHERITED; /* | X | | | */ /* | | | | */ /* Class implements interface(s); | | | | */ - public const ZEND_ACC_IMPLEMENT_INTERFACES = (1 << 14); /* | X | | | */ +// public const ZEND_ACC_IMPLEMENT_INTERFACES = Defines::ZEND_ACC_IMPLEMENT_INTERFACES; /* | X | | | */ /* | | | | */ /* Class uses trait(s); | | | | */ - public const ZEND_ACC_IMPLEMENT_TRAITS = (1 << 15); /* | X | | | */ +// public const ZEND_ACC_IMPLEMENT_TRAITS = Defines::ZEND_ACC_IMPLEMENT_TRAITS; /* | X | | | */ /* | | | | */ /* User class has methods with static variables | | | | */ - public const ZEND_HAS_STATIC_IN_METHODS = (1 << 16); /* | X | | | */ + public const ZEND_HAS_STATIC_IN_METHODS = Defines::ZEND_HAS_STATIC_IN_METHODS; /* | X | | | */ /* | | | | */ /* Whether all property types are resolved to CEs | | | | */ - public const ZEND_ACC_PROPERTY_TYPES_RESOLVED = (1 << 17); /* | X | | | */ +// public const ZEND_ACC_PROPERTY_TYPES_RESOLVED = Defines::ZEND_ACC_PROPERTY_TYPES_RESOLVED; /* | X | | | */ /* | | | | */ /* Children must reuse parent get_iterator(); | | | | */ - public const ZEND_ACC_REUSE_GET_ITERATOR = (1 << 18); /* | X | | | */ + public const ZEND_ACC_REUSE_GET_ITERATOR = Defines::ZEND_ACC_REUSE_GET_ITERATOR; /* | X | | | */ /* | | | | */ /* Parent class is resolved (CE);. | | | | */ - public const ZEND_ACC_RESOLVED_PARENT = (1 << 19); /* | X | | | */ + public const ZEND_ACC_RESOLVED_PARENT = Defines::ZEND_ACC_RESOLVED_PARENT; /* | X | | | */ /* | | | | */ /* Interfaces are resolved (CEs);. | | | | */ - public const ZEND_ACC_RESOLVED_INTERFACES = (1 << 20); /* | X | | | */ + public const ZEND_ACC_RESOLVED_INTERFACES = Defines::ZEND_ACC_RESOLVED_INTERFACES; /* | X | | | */ /* | | | | */ /* Class has unresolved variance obligations. | | | | */ - public const ZEND_ACC_UNRESOLVED_VARIANCE = (1 << 21); /* | X | | | */ + public const ZEND_ACC_UNRESOLVED_VARIANCE = Defines::ZEND_ACC_UNRESOLVED_VARIANCE; /* | X | | | */ /* | | | | */ /* Function Flags (unused: 28...30); | | | | */ /* ============== | | | | */ /* | | | | */ /* deprecation flag | | | | */ - public const ZEND_ACC_DEPRECATED = (1 << 11); /* | | X | | */ + public const ZEND_ACC_DEPRECATED = Defines::ZEND_ACC_DEPRECATED; /* | | X | | */ /* | | | | */ /* Function returning by reference | | | | */ - public const ZEND_ACC_RETURN_REFERENCE = (1 << 12); /* | | X | | */ + public const ZEND_ACC_RETURN_REFERENCE = Defines::ZEND_ACC_RETURN_REFERENCE; /* | | X | | */ /* | | | | */ /* Function has a return type | | | | */ - public const ZEND_ACC_HAS_RETURN_TYPE = (1 << 13); /* | | X | | */ + public const ZEND_ACC_HAS_RETURN_TYPE = Defines::ZEND_ACC_HAS_RETURN_TYPE; /* | | X | | */ /* | | | | */ /* Function with variable number of arguments | | | | */ - public const ZEND_ACC_VARIADIC = (1 << 14); /* | | X | | */ + public const ZEND_ACC_VARIADIC = Defines::ZEND_ACC_VARIADIC; /* | | X | | */ /* | | | | */ /* op_array has finally blocks (user only); | | | | */ - public const ZEND_ACC_HAS_FINALLY_BLOCK = (1 << 15); /* | | X | | */ + public const ZEND_ACC_HAS_FINALLY_BLOCK = Defines::ZEND_ACC_HAS_FINALLY_BLOCK; /* | | X | | */ /* | | | | */ /* "main" op_array with | | | | */ /* ZEND_DECLARE_CLASS_DELAYED opcodes | | | | */ - public const ZEND_ACC_EARLY_BINDING = (1 << 16); /* | | X | | */ + public const ZEND_ACC_EARLY_BINDING = Defines::ZEND_ACC_EARLY_BINDING; /* | | X | | */ /* | | | | */ /* call through user function trampoline. e.g. | | | | */ /* __call, __callstatic | | | | */ - public const ZEND_ACC_CALL_VIA_TRAMPOLINE = (1 << 18); /* | | X | | */ + public const ZEND_ACC_CALL_VIA_TRAMPOLINE = Defines::ZEND_ACC_CALL_VIA_TRAMPOLINE; /* | | X | | */ /* | | | | */ /* disable inline caching | | | | */ - public const ZEND_ACC_NEVER_CACHE = (1 << 19); /* | | X | | */ + public const ZEND_ACC_NEVER_CACHE = Defines::ZEND_ACC_NEVER_CACHE; /* | | X | | */ /* | | | | */ /* Closure related | | | | */ - public const ZEND_ACC_CLOSURE = (1 << 20); /* | | X | | */ - public const ZEND_ACC_FAKE_CLOSURE = (1 << 21); /* | | X | | */ + public const ZEND_ACC_CLOSURE = Defines::ZEND_ACC_CLOSURE; /* | | X | | */ + public const ZEND_ACC_FAKE_CLOSURE = Defines::ZEND_ACC_FAKE_CLOSURE; /* | | X | | */ /* | | | | */ /* run_time_cache allocated on heap (user only); | | | | */ - public const ZEND_ACC_HEAP_RT_CACHE = (1 << 22); /* | | X | | */ + public const ZEND_ACC_HEAP_RT_CACHE = Defines::ZEND_ACC_HEAP_RT_CACHE; /* | | X | | */ /* | | | | */ /* method flag used by Closure::__invoke(); | | | | */ - public const ZEND_ACC_USER_ARG_INFO = (1 << 23); /* | | X | | */ + public const ZEND_ACC_USER_ARG_INFO = Defines::ZEND_ACC_USER_ARG_INFO; /* | | X | | */ /* | | | | */ - public const ZEND_ACC_GENERATOR = (1 << 24); /* | | X | | */ + public const ZEND_ACC_GENERATOR = Defines::ZEND_ACC_GENERATOR; /* | | X | | */ /* | | | | */ - public const ZEND_ACC_DONE_PASS_TWO = (1 << 25); /* | | X | | */ + public const ZEND_ACC_DONE_PASS_TWO = Defines::ZEND_ACC_DONE_PASS_TWO; /* | | X | | */ /* | | | | */ /* internal function is allocated at arena (int only); | | | | */ - public const ZEND_ACC_ARENA_ALLOCATED = (1 << 26); /* | | X | | */ + public const ZEND_ACC_ARENA_ALLOCATED = Defines::ZEND_ACC_ARENA_ALLOCATED; /* | | X | | */ /* | | | | */ /* op_array is a clone of trait method | | | | */ - public const ZEND_ACC_TRAIT_CLONE = (1 << 27); /* | | X | | */ + public const ZEND_ACC_TRAIT_CLONE = Defines::ZEND_ACC_TRAIT_CLONE; /* | | X | | */ /* | | | | */ /* functions is a constructor | | | | */ - public const ZEND_ACC_CTOR = (1 << 28); /* | | X | | */ + public const ZEND_ACC_CTOR = Defines::ZEND_ACC_CTOR; /* | | X | | */ /* | | | | */ /* function is a destructor | | | | */ - public const ZEND_ACC_DTOR = (1 << 29); /* | | X | | */ +// public const ZEND_ACC_DTOR = Defines::ZEND_ACC_DTOR; /* | | X | | */ /* | | | | */ /* op_array uses strict mode types | | | | */ - public const ZEND_ACC_STRICT_TYPES = (1 << 31); /* | | X | | */ + public const ZEND_ACC_STRICT_TYPES = Defines::ZEND_ACC_STRICT_TYPES; /* | | X | | */ - public const ZEND_ACC_PPP_MASK = self::ZEND_ACC_PUBLIC | self::ZEND_ACC_PROTECTED | self::ZEND_ACC_PRIVATE; + public const ZEND_ACC_PPP_MASK = Defines::ZEND_ACC_PPP_MASK; /** * Type of zend_function.type */ - public const ZEND_INTERNAL_FUNCTION = 1; - public const ZEND_USER_FUNCTION = 2; - public const ZEND_EVAL_CODE = 4; + public const ZEND_INTERNAL_FUNCTION = Defines::ZEND_INTERNAL_FUNCTION; + public const ZEND_USER_FUNCTION = Defines::ZEND_USER_FUNCTION; + public const ZEND_EVAL_CODE = Defines::ZEND_EVAL_CODE; - public const ZEND_INTERNAL_CLASS = 1; - public const ZEND_USER_CLASS = 2; + public const ZEND_INTERNAL_CLASS = Defines::ZEND_INTERNAL_CLASS; + public const ZEND_USER_CLASS = Defines::ZEND_USER_CLASS; /** * User opcode handler return values */ - public const ZEND_USER_OPCODE_CONTINUE = 0; /* execute next opcode */ - public const ZEND_USER_OPCODE_RETURN = 1; /* exit from executor (return from function) */ - public const ZEND_USER_OPCODE_DISPATCH = 2; /* call original opcode handler */ - public const ZEND_USER_OPCODE_ENTER = 3; /* enter into new op_array without recursion */ - public const ZEND_USER_OPCODE_LEAVE = 4; /* return to calling op_array within the same executor */ - public const ZEND_USER_OPCODE_DISPATCH_TO = 0x100; /* call original handler of returned opcode */ - + public const ZEND_USER_OPCODE_CONTINUE = Defines::ZEND_USER_OPCODE_CONTINUE; /* execute next opcode */ + public const ZEND_USER_OPCODE_RETURN = Defines::ZEND_USER_OPCODE_RETURN; /* exit from executor (return from function) */ + public const ZEND_USER_OPCODE_DISPATCH = Defines::ZEND_USER_OPCODE_DISPATCH; /* call original opcode handler */ + public const ZEND_USER_OPCODE_ENTER = Defines::ZEND_USER_OPCODE_ENTER; /* enter into new op_array without recursion */ + public const ZEND_USER_OPCODE_LEAVE = Defines::ZEND_USER_OPCODE_LEAVE; /* return to calling op_array within the same executor */ + public const ZEND_USER_OPCODE_DISPATCH_TO = Defines::ZEND_USER_OPCODE_DISPATCH_TO; /* call original handler of returned opcode */ + // TODO figure out the tyepdef enum public const SUCCESS = 0; public const FAILURE = -1; /** * This should be equal to ZEND_MM_ALIGNMENT */ - public const MM_ALIGNMENT = 8; + public const MM_ALIGNMENT = Defines::ZEND_MM_ALIGNMENT; /** * Provides an access to the executor global state @@ -228,14 +228,7 @@ class Core */ public static function init() { - $isThreadSafe = ZEND_THREAD_SAFE; $isWindowsPlatform = stripos(PHP_OS, 'WIN') === 0; - $is64BitPlatform = PHP_INT_SIZE === 8; - - // TODO: support ts/nts x86/x64 combination - if ($isThreadSafe || !$is64BitPlatform) { - throw new \RuntimeException('Only x64 non thread-safe versions of PHP are supported'); - } try { $engine = FFI::scope('ZEngine'); @@ -244,8 +237,7 @@ public static function init() throw new \RuntimeException('Preload mode requires that you call Core::preload before'); } // If not, then load definitions by hand - $fname = "engine_".PHP_MAJOR_VERSION."_" . PHP_MINOR_VERSION . "_" . (PHP_INT_SIZE === 8 ? "x64" : "x32") . "_" . (ZEND_THREAD_SAFE ? "zts" : "nts") . ".h"; - $definition = file_get_contents(DefinitionLoader::wrap(__DIR__.'/../include/'.$fname)); + $definition = require_once __DIR__ . "/../include/engine.php"; $arguments = [$definition]; // For Windows platform we should load symbols from the shared php7.dll library @@ -257,9 +249,21 @@ public static function init() } self::$engine = $engine; - assert(!$isThreadSafe, 'Following properties available only for non thread-safe version'); - self::$executor = new Executor($engine->executor_globals); - self::$compiler = new Compiler($engine->compiler_globals); + if(ZEND_THREAD_SAFE) { + // #define CG(v) ZEND_TSRMG_FAST(compiler_globals_offset, zend_compiler_globals *, v) + // #define ZEND_TSRMG_FAST TSRMG_FAST + // #define TSRMG_FAST(offset, type, element) (TSRMG_FAST_BULK(offset, type)->element) + // #define TSRMG_FAST_BULK(offset, type) ((type) (((char*) tsrm_get_ls_cache())+(offset))) + // (zend_compiler_globals *) ((char*) tsrm_get_ls_cache()+compiler_globals_offset) + $executorGlobals = FFI::cast($engine->type("zend_executor_globals*"), FFI::cast("char*", $engine->tsrm_get_ls_cache()) + $engine->executor_globals_offset); + $compilerGlobals = FFI::cast($engine->type("zend_compiler_globals*"), FFI::cast("char*", $engine->tsrm_get_ls_cache()) + $engine->compiler_globals_offset); + self::$executor = new Executor($executorGlobals); + self::$compiler = new Compiler($compilerGlobals); + } else { + // # define CG(v) (compiler_globals.v) + self::$executor = new Executor($engine->executor_globals); + self::$compiler = new Compiler($engine->compiler_globals); + } self::$modules = new HashTable(Core::addr($engine->module_registry)); self::preloadFrameworkClasses(); @@ -270,8 +274,7 @@ public static function init() */ public static function preload() { - $fname = "engine_".PHP_MAJOR_VERSION."_" . PHP_MINOR_VERSION . "_" . (PHP_INT_SIZE === 8 ? "x64" : "x32") . "_" . (ZEND_THREAD_SAFE ? "zts" : "nts") . ".h"; - $definition = file_get_contents(DefinitionLoader::wrap(__DIR__.'/../include/'.$fname)); + $definition = require_once __DIR__ . "/../include/engine.php"; try { $tempFile = tempnam(sys_get_temp_dir(), 'php_ffi'); file_put_contents($tempFile, $definition); diff --git a/src/EngineExtension/AbstractModule.php b/src/EngineExtension/AbstractModule.php index 70c4dcc..300ba98 100644 --- a/src/EngineExtension/AbstractModule.php +++ b/src/EngineExtension/AbstractModule.php @@ -13,6 +13,7 @@ namespace ZEngine\EngineExtension; use FFI\CData; +use ZEngine\Constants\Defines; use ZEngine\Core; use ZEngine\EngineExtension\Hook\ExtensionConstructorHook; use ZEngine\Reflection\ReflectionExtension; @@ -22,12 +23,12 @@ abstract class AbstractModule extends ReflectionExtension implements ModuleInter /** * @see zend_modules.h:MODULE_PERSISTENT */ - private const MODULE_PERSISTENT = 1; + private const MODULE_PERSISTENT = Defines::MODULE_PERSISTENT; /** * @see zend_modules.h:MODULE_TEMPORARY */ - private const MODULE_TEMPORARY = 2; + private const MODULE_TEMPORARY = Defines::MODULE_TEMPORARY; /** * Unique name of this module @@ -93,7 +94,11 @@ final public function register(): void if ($globalType !== null) { $module->globals_size = Core::sizeof(Core::type($globalType)); $memoryStructure = Core::new($globalType, false, static::targetPersistent()); - $module->globals_ptr = Core::addr($memoryStructure); + if(ZEND_THREAD_SAFE) { + throw new \LogicException("TODO"); + } else { + $module->globals_ptr = Core::addr($memoryStructure); + } } // $module pointer will be updated, as registration method returns a copy of memory diff --git a/src/EngineExtension/ModuleDependency.php b/src/EngineExtension/ModuleDependency.php index b4a3b8e..fd9d440 100644 --- a/src/EngineExtension/ModuleDependency.php +++ b/src/EngineExtension/ModuleDependency.php @@ -14,6 +14,7 @@ use FFI\CData; +use ZEngine\Constants\Defines; /** * Class ModuleDependency @@ -27,9 +28,9 @@ */ class ModuleDependency { - public const MODULE_REQUIRED = 1; - public const MODULE_CONFLICTS = 2; - public const MODULE_OPTIONAL = 3; + public const MODULE_REQUIRED = Defines::MODULE_DEP_REQUIRED; + public const MODULE_CONFLICTS = Defines::MODULE_DEP_CONFLICTS; + public const MODULE_OPTIONAL = Defines::MODULE_DEP_OPTIONAL; /** * Holds a _zend_module_dep structure diff --git a/src/Macro/DefinitionLoader.php b/src/Macro/DefinitionLoader.php deleted file mode 100644 index 7dffd4c..0000000 --- a/src/Macro/DefinitionLoader.php +++ /dev/null @@ -1,129 +0,0 @@ - - * - * This source file is subject to the license that is bundled - * with this source code in the file LICENSE. - * - */ -declare(strict_types=1); - -namespace ZEngine\Macro; - -use php_user_filter as PhpStreamFilter; -use RuntimeException; - -class DefinitionLoader extends PhpStreamFilter -{ - /** - * Default PHP filter name for registration - */ - private const FILTER_IDENTIFIER = 'z-engine.def.loader'; - - /** - * String buffer - */ - private string $data = ''; - - /** - * {@inheritdoc} - */ - public function filter($in, $out, &$consumed, $closing) - { - /** Simple pattern to match if(n?)def..endif constructions */ - static $pattern = '/^#(ifn?def) +(.*?)\n([\s\S]*?)(#endif)/m'; - - while ($bucket = stream_bucket_make_writeable($in)) { - $this->data .= $bucket->data; - } - - if ($closing || feof($this->stream)) { - $consumed = strlen($this->data); - - $macros = $this->resolveSystemMacros(); - // Now we emulate resolution of ifdef..endif constructions - $transformedData = $this->data; - $transformedData = preg_replace_callback($pattern, function (array $matches) use ($macros): string { - [, $keyword, $macro, $body] = $matches; - if ($keyword === 'ifdef' && !isset($macros[$macro])) { - $body = ''; - } elseif ($keyword === 'ifndef' && isset($macros[$macro])) { - $body = ''; - } - - return $body; - }, $transformedData); - - // Simple macros resolving via strtr - $transformedData = strtr($transformedData, $macros); - - $bucket = stream_bucket_new($this->stream, $transformedData); - stream_bucket_append($out, $bucket); - - return PSFS_PASS_ON; - } - - return PSFS_FEED_ME; - } - - /** - * Wraps given filename with stream resolver - * - * @param string $filename - */ - public static function wrap(string $filename): string - { - // Let's perform self-registration on first query - if (!in_array(self::FILTER_IDENTIFIER, stream_get_filters(), true)) { - self::register(); - } - - return 'php://filter/read=' . self::FILTER_IDENTIFIER . '/resource=' . $filename; - } - - /** - * Register current loader as stream filter in PHP - * - * @throws RuntimeException If registration was failed - */ - private static function register(): void - { - $result = stream_filter_register(self::FILTER_IDENTIFIER, self::class); - if ($result === false) { - throw new RuntimeException('Stream filter was not registered'); - } - } - - private function resolveSystemMacros(): array - { - $isThreadSafe = ZEND_THREAD_SAFE; - $isWindowsPlatform = stripos(PHP_OS, 'WIN') === 0; - $is64BitPlatform = PHP_INT_SIZE === 8; - - // TODO: support ts/nts x86/x64 combination - if ($isThreadSafe || !$is64BitPlatform) { - throw new \RuntimeException('Only x64 non thread-safe versions of PHP are supported'); - } - - $macros = [ - 'ZEND_API' => '__declspec(dllimport)', - 'ZEND_FASTCALL' => $isWindowsPlatform ? '__vectorcall' : '', - - 'ZEND_MAX_RESERVED_RESOURCES' => '6', - 'INTERNAL_FUNCTION_PARAMETERS' => 'zend_execute_data *execute_data, zval *return_value', - 'ZEND_LIBRARY_NAME' => $isWindowsPlatform ? 'php7.dll' : '', - ]; - - if ($isWindowsPlatform) { - $macros['ZEND_WIN32'] = '1'; - } - - if ($isThreadSafe) { - $macros['ZTS'] = '1'; - } - - return $macros; - } -} diff --git a/src/Reflection/ReflectionClass.php b/src/Reflection/ReflectionClass.php index 504a24f..839f696 100644 --- a/src/Reflection/ReflectionClass.php +++ b/src/Reflection/ReflectionClass.php @@ -121,7 +121,7 @@ public static function fromCData(CData $classEntry): ReflectionClass /** * @inheritDoc */ - public function getName() + public function getName(): string { return StringEntry::fromCData($this->pointer->name)->getStringValue(); } @@ -264,7 +264,7 @@ public function removeInterfaces(string ...$interfaceNames): void /** * @inheritDoc */ - public function getMethod($name) + public function getMethod($name): ReflectionMethod { $functionEntry = $this->methodTable->find(strtolower($name)); if ($functionEntry === null) { @@ -278,7 +278,7 @@ public function getMethod($name) * @inheritDoc * @return ReflectionMethod[] */ - public function getMethods($filter = null) + public function getMethods($filter = null): array { $methods = []; foreach ($this->methodTable as $methodEntryValue) { @@ -321,12 +321,12 @@ public function addMethod(string $methodName, \Closure $method): ReflectionMetho return $refMethod; } - public function isInternal() + public function isInternal(): bool { return ord($this->pointer->type) === Core::ZEND_INTERNAL_CLASS; } - public function isUserDefined() + public function isUserDefined(): bool { return ord($this->pointer->type) === Core::ZEND_USER_CLASS; } @@ -453,13 +453,14 @@ public function removeTraits(string ...$traitNames): void $this->pointer->num_traits = $numResultTraits; } + #[\ReturnTypeWillChange] /** * @inheritDoc */ - public function getParentClass(): ?ReflectionClass + public function getParentClass()// : ReflectionClass|False { if (!$this->hasParentClass()) { - return null; + return false; } // For linked class we should look at parent name directly @@ -603,7 +604,7 @@ public function setFileName(string $newFileName): void * * @return iterable|ReflectionValue[] */ - public function getDefaultProperties(): iterable + public function getDefaultProperties(): array { $iterator = function () { $propertyIndex = 0; @@ -640,7 +641,7 @@ public function getDefaultStaticMembers(): iterable * @inheritDoc * @return ReflectionClassConstant */ - public function getReflectionConstant($name) + public function getReflectionConstant($name): ReflectionClassConstant { $constantEntry = $this->constantsTable->find($name); if ($constantEntry === null) { @@ -915,7 +916,7 @@ private function initLowLevelStructures(CData $classEntry): void $this->methodTable = new HashTable(Core::addr($classEntry->function_table)); $this->propertiesTable = new HashTable(Core::addr($classEntry->properties_info)); $this->constantsTable = new HashTable(Core::addr($classEntry->constants_table)); - if ($classEntry->attributes !== null) { + if (version_compare(PHP_VERSION, "8.0.0", ">=") && $classEntry->attributes !== null) { $this->attributesTable = new HashTable(Core::addr($classEntry->attributes)); } } diff --git a/src/Reflection/ReflectionClassConstant.php b/src/Reflection/ReflectionClassConstant.php index 559fa2e..1ebbd75 100644 --- a/src/Reflection/ReflectionClassConstant.php +++ b/src/Reflection/ReflectionClassConstant.php @@ -74,13 +74,23 @@ public static function fromCData(CData $constantEntry, string $constantName): Re return $reflectionConstant; } + private function setPermission(int $level): void + { + if(version_compare(PHP_VERSION, "8.1.0", "<")) { + $this->pointer->value->u2->access_flags &= (~Core::ZEND_ACC_PPP_MASK); + $this->pointer->value->u2->access_flags |= $level; + } else { + $this->pointer->value->u2->constant_flags &= (~Core::ZEND_ACC_PPP_MASK); + $this->pointer->value->u2->constant_flags |= $level; + } + } + /** * Declares constant as public */ public function setPublic(): void { - $this->pointer->value->u2->access_flags &= (~Core::ZEND_ACC_PPP_MASK); - $this->pointer->value->u2->access_flags |= Core::ZEND_ACC_PUBLIC; + $this->setPermission(Core::ZEND_ACC_PUBLIC); } /** @@ -88,8 +98,7 @@ public function setPublic(): void */ public function setProtected(): void { - $this->pointer->value->u2->access_flags &= (~Core::ZEND_ACC_PPP_MASK); - $this->pointer->value->u2->access_flags |= Core::ZEND_ACC_PROTECTED; + $this->setPermission(Core::ZEND_ACC_PROTECTED); } /** @@ -97,8 +106,7 @@ public function setProtected(): void */ public function setPrivate(): void { - $this->pointer->value->u2->access_flags &= (~Core::ZEND_ACC_PPP_MASK); - $this->pointer->value->u2->access_flags |= Core::ZEND_ACC_PRIVATE; + $this->setPermission(Core::ZEND_ACC_PRIVATE); } /** diff --git a/src/Reflection/ReflectionExtension.php b/src/Reflection/ReflectionExtension.php index dce8c8e..97024f6 100644 --- a/src/Reflection/ReflectionExtension.php +++ b/src/Reflection/ReflectionExtension.php @@ -109,7 +109,11 @@ public function getGlobalsSize(): int */ public function getGlobals(): ?CData { - return $this->moduleEntry->globals_ptr; + if(ZEND_THREAD_SAFE) { + throw new \LogicException("TODO"); + } else { + return $this->moduleEntry->globals_ptr; + } } /** diff --git a/src/Reflection/ReflectionMethod.php b/src/Reflection/ReflectionMethod.php index 65b9fc7..b119d73 100644 --- a/src/Reflection/ReflectionMethod.php +++ b/src/Reflection/ReflectionMethod.php @@ -167,12 +167,12 @@ public function setDeclaringClass(string $className): void } /** - * Returns the method prototype or null if no prototype for this method + * Returns the method prototype for this method */ - public function getPrototype(): ?ReflectionMethod + public function getPrototype(): ReflectionMethod { if ($this->getCommonPointer()->prototype === null) { - return null; + throw new \ReflectionException(); } return static::fromCData($this->getCommonPointer()->prototype); diff --git a/src/Reflection/ReflectionValue.php b/src/Reflection/ReflectionValue.php index f4587e9..8421133 100644 --- a/src/Reflection/ReflectionValue.php +++ b/src/Reflection/ReflectionValue.php @@ -14,6 +14,7 @@ use FFI\CData; use ReflectionClass as NativeReflectionClass; +use ZEngine\Constants\Defines; use ZEngine\Core; use ZEngine\Type\ReferenceCountedInterface; use ZEngine\Type\ReferenceCountedTrait; @@ -74,40 +75,40 @@ class ReflectionValue implements ReferenceCountedInterface use ReferenceCountedTrait; /* regular data types */ - public const IS_UNDEF = 0; - public const IS_NULL = 1; - public const IS_FALSE = 2; - public const IS_TRUE = 3; - public const IS_LONG = 4; - public const IS_DOUBLE = 5; - public const IS_STRING = 6; - public const IS_ARRAY = 7; - public const IS_OBJECT = 8; - public const IS_RESOURCE = 9; - public const IS_REFERENCE = 10; - public const IS_CONSTANT_AST = 11; /* constant expressions */ + public const IS_UNDEF = Defines::IS_UNDEF; + public const IS_NULL = Defines::IS_NULL; + public const IS_FALSE = Defines::IS_FALSE; + public const IS_TRUE = Defines::IS_TRUE; + public const IS_LONG = Defines::IS_LONG; + public const IS_DOUBLE = Defines::IS_DOUBLE; + public const IS_STRING = Defines::IS_STRING; + public const IS_ARRAY = Defines::IS_ARRAY; + public const IS_OBJECT = Defines::IS_OBJECT; + public const IS_RESOURCE = Defines::IS_RESOURCE; + public const IS_REFERENCE = Defines::IS_REFERENCE; + public const IS_CONSTANT_AST = Defines::IS_CONSTANT_AST; /** * Fake types used only for type hinting. * These are allowed to overlap with the types below. */ - public const IS_CALLABLE = 12; - public const IS_ITERABLE = 13; - public const IS_VOID = 14; - public const IS_STATIC = 15; - public const IS_MIXED = 16; + public const IS_CALLABLE = Defines::IS_CALLABLE; + public const IS_ITERABLE = Defines::IS_ITERABLE; + public const IS_VOID = Defines::IS_VOID; +// public const IS_STATIC = Defines::IS_STATIC; +// public const IS_MIXED = Defines::IS_MIXED; /* internal types */ - public const IS_INDIRECT = 12; - public const IS_PTR = 13; - public const IS_ALIAS_PTR = 14; - public const _IS_ERROR = 15; + public const IS_INDIRECT = Defines::IS_INDIRECT; + public const IS_PTR = Defines::IS_PTR; +// public const IS_ALIAS_PTR = Defines::IS_ALIAS_PTR; + public const _IS_ERROR = Defines::_IS_ERROR; /* used for casts */ - public const _IS_BOOL = 17; - public const _IS_NUMBER = 18; + public const _IS_BOOL = Defines::_IS_BOOL; + public const _IS_NUMBER = Defines::_IS_NUMBER; - private const Z_TYPE_FLAGS_MASK = 0xFF00; + private const Z_TYPE_FLAGS_MASK = Defines::Z_TYPE_FLAGS_MASK; /** * Stores the pointer to zval structure, associated with this variable diff --git a/src/System/Compiler.php b/src/System/Compiler.php index ef38f5b..c044cee 100644 --- a/src/System/Compiler.php +++ b/src/System/Compiler.php @@ -15,6 +15,7 @@ use FFI\CData; use ZEngine\AbstractSyntaxTree\NodeFactory; use ZEngine\AbstractSyntaxTree\NodeInterface; +use ZEngine\Constants\Defines; use ZEngine\Core; use ZEngine\Reflection\ReflectionValue; use ZEngine\Type\HashTable; @@ -27,65 +28,65 @@ class Compiler */ /* generate extended debug information */ - public const COMPILE_EXTENDED_STMT = (1 << 0); - public const COMPILE_EXTENDED_FCALL = (1 << 1); - public const COMPILE_EXTENDED_INFO = (self::COMPILE_EXTENDED_STMT | self::COMPILE_EXTENDED_FCALL); + public const COMPILE_EXTENDED_STMT = Defines::ZEND_COMPILE_EXTENDED_STMT; + public const COMPILE_EXTENDED_FCALL = Defines::ZEND_COMPILE_EXTENDED_FCALL; + public const COMPILE_EXTENDED_INFO = Defines::ZEND_COMPILE_EXTENDED_INFO; /* call op_array handler of extendions */ - public const COMPILE_HANDLE_OP_ARRAY = (1 << 2); + public const COMPILE_HANDLE_OP_ARRAY = Defines::ZEND_COMPILE_HANDLE_OP_ARRAY; /* generate INIT_FCALL_BY_NAME for internal functions instead of INIT_FCALL */ - public const COMPILE_IGNORE_INTERNAL_FUNCTIONS = (1 << 3); + public const COMPILE_IGNORE_INTERNAL_FUNCTIONS = Defines::ZEND_COMPILE_IGNORE_INTERNAL_FUNCTIONS; /* don't perform early binding for classes inherited form internal ones; * in namespaces assume that internal class that doesn't exist at compile-time * may apper in run-time */ - public const COMPILE_IGNORE_INTERNAL_CLASSES = (1 << 4); + public const COMPILE_IGNORE_INTERNAL_CLASSES = Defines::ZEND_COMPILE_IGNORE_INTERNAL_CLASSES; /* generate DECLARE_CLASS_DELAYED opcode to delay early binding */ - public const COMPILE_DELAYED_BINDING = (1 << 5); + public const COMPILE_DELAYED_BINDING = Defines::ZEND_COMPILE_DELAYED_BINDING; /* disable constant substitution at compile-time */ - public const COMPILE_NO_CONSTANT_SUBSTITUTION = (1 << 6); + public const COMPILE_NO_CONSTANT_SUBSTITUTION = Defines::ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION; /* disable usage of builtin instruction for strlen() */ - public const COMPILE_NO_BUILTIN_STRLEN = (1 << 7); +// public const COMPILE_NO_BUILTIN_STRLEN = Defines::ZEND_COMPILE_NO_BUILTIN_STRLEN; /* disable substitution of persistent constants at compile-time */ - public const COMPILE_NO_PERSISTENT_CONSTANT_SUBSTITUTION = (1 << 8); + public const COMPILE_NO_PERSISTENT_CONSTANT_SUBSTITUTION = Defines::ZEND_COMPILE_NO_PERSISTENT_CONSTANT_SUBSTITUTION; /* generate INIT_FCALL_BY_NAME for userland functions instead of INIT_FCALL */ - public const COMPILE_IGNORE_USER_FUNCTIONS = (1 << 9); + public const COMPILE_IGNORE_USER_FUNCTIONS = Defines::ZEND_COMPILE_IGNORE_USER_FUNCTIONS; /* force ACC_USE_GUARDS for all classes */ - public const COMPILE_GUARDS = (1 << 10); + public const COMPILE_GUARDS = Defines::ZEND_COMPILE_GUARDS; /* disable builtin special case function calls */ - public const COMPILE_NO_BUILTINS = (1 << 11); + public const COMPILE_NO_BUILTINS = Defines::ZEND_COMPILE_NO_BUILTINS; /* result of compilation may be stored in file cache */ - public const COMPILE_WITH_FILE_CACHE = (1 << 12); + public const COMPILE_WITH_FILE_CACHE = Defines::ZEND_COMPILE_WITH_FILE_CACHE; /* ignore functions and classes declared in other files */ - public const COMPILE_IGNORE_OTHER_FILES = (1 << 13); + public const COMPILE_IGNORE_OTHER_FILES = Defines::ZEND_COMPILE_IGNORE_OTHER_FILES; /* this flag is set when compiler invoked by opcache_compile_file() */ - public const COMPILE_WITHOUT_EXECUTION = (1 << 14); + public const COMPILE_WITHOUT_EXECUTION = Defines::ZEND_COMPILE_WITHOUT_EXECUTION; /* this flag is set when compiler invoked during preloading */ - public const COMPILE_PRELOAD = (1 << 15); + public const COMPILE_PRELOAD = Defines::ZEND_COMPILE_PRELOAD; /* disable jumptable optimization for switch statements */ - public const COMPILE_NO_JUMPTABLES = (1 << 16); + public const COMPILE_NO_JUMPTABLES = Defines::ZEND_COMPILE_NO_JUMPTABLES; /* this flag is set when compiler invoked during preloading in separate process */ - public const COMPILE_PRELOAD_IN_CHILD = (1 << 17); + public const COMPILE_PRELOAD_IN_CHILD = Defines::ZEND_COMPILE_PRELOAD_IN_CHILD; /* The default value for CG(compiler_options) */ - public const COMPILE_DEFAULT = self::COMPILE_HANDLE_OP_ARRAY; + public const COMPILE_DEFAULT = Defines::ZEND_COMPILE_DEFAULT; /* The default value for CG(compiler_options) during eval() */ - public const COMPILE_DEFAULT_FOR_EVAL = 0; + public const COMPILE_DEFAULT_FOR_EVAL = Defines::ZEND_COMPILE_DEFAULT_FOR_EVAL; /** * Contains a hashtable with all registered classes diff --git a/src/System/ObjectStore.php b/src/System/ObjectStore.php index c817be5..7fc5e2c 100644 --- a/src/System/ObjectStore.php +++ b/src/System/ObjectStore.php @@ -15,6 +15,7 @@ use ArrayAccess; use Countable; use FFI\CData; +use ZEngine\Constants\Defines; use ZEngine\Core; use ZEngine\Type\ObjectEntry; @@ -23,7 +24,7 @@ final class ObjectStore implements Countable, ArrayAccess /** * @see zend_objects_API.h:OBJ_BUCKET_INVALID macro */ - private const OBJ_BUCKET_INVALID = 1<<0; + private const OBJ_BUCKET_INVALID = Defines::OBJ_BUCKET_INVALID; /** * Holds an internal pointer to the EG(objects_store) diff --git a/src/System/OpCode.php b/src/System/OpCode.php index b0b9965..ca7aa18 100644 --- a/src/System/OpCode.php +++ b/src/System/OpCode.php @@ -14,6 +14,7 @@ use Closure; use FFI\CData; +use ZEngine\Constants\Defines; use ZEngine\Core; /** @@ -21,207 +22,207 @@ */ final class OpCode { - public const NOP = 0; + public const NOP = Defines::ZEND_NOP; - public const ADD = 1; - public const SUB = 2; - public const MUL = 3; - public const DIV = 4; - public const MOD = 5; - public const SL = 6; - public const SR = 7; - public const CONCAT = 8; - public const BW_OR = 9; - public const BW_AND = 10; - public const BW_XOR = 11; - public const POW = 12; - public const BW_NOT = 13; - public const BOOL_NOT = 14; - public const BOOL_XOR = 15; - public const IS_IDENTICAL = 16; - public const IS_NOT_IDENTICAL = 17; - public const IS_EQUAL = 18; - public const IS_NOT_EQUAL = 19; - public const IS_SMALLER = 20; - public const IS_SMALLER_OR_EQUAL = 21; - public const ASSIGN = 22; - public const ASSIGN_DIM = 23; - public const ASSIGN_OBJ = 24; - public const ASSIGN_STATIC_PROP = 25; - public const ASSIGN_OP = 26; - public const ASSIGN_DIM_OP = 27; - public const ASSIGN_OBJ_OP = 28; - public const ASSIGN_STATIC_PROP_OP = 29; - public const ASSIGN_REF = 30; - public const QM_ASSIGN = 31; - public const ASSIGN_OBJ_REF = 32; - public const ASSIGN_STATIC_PROP_REF = 33; - public const PRE_INC = 34; - public const PRE_DEC = 35; - public const POST_INC = 36; - public const POST_DEC = 37; - public const PRE_INC_STATIC_PROP = 38; - public const PRE_DEC_STATIC_PROP = 39; - public const POST_INC_STATIC_PROP = 40; - public const POST_DEC_STATIC_PROP = 41; - public const JMP = 42; - public const JMPZ = 43; - public const JMPNZ = 44; - public const JMPZNZ = 45; - public const JMPZ_EX = 46; - public const JMPNZ_EX = 47; - public const CASE = 48; - public const CHECK_VAR = 49; - public const SEND_VAR_NO_REF_EX = 50; - public const CAST = 51; - public const BOOL = 52; - public const FAST_CONCAT = 53; - public const ROPE_INIT = 54; - public const ROPE_ADD = 55; - public const ROPE_END = 56; - public const BEGIN_SILENCE = 57; - public const END_SILENCE = 58; - public const INIT_FCALL_BY_NAME = 59; - public const DO_FCALL = 60; - public const INIT_FCALL = 61; - public const RETURN = 62; - public const RECV = 63; - public const RECV_INIT = 64; - public const SEND_VAL = 65; - public const SEND_VAR_EX = 66; - public const SEND_REF = 67; - public const NEW = 68; - public const INIT_NS_FCALL_BY_NAME = 69; - public const FREE = 70; - public const INIT_ARRAY = 71; - public const ADD_ARRAY_ELEMENT = 72; - public const INCLUDE_OR_EVAL = 73; - public const UNSET_VAR = 74; - public const UNSET_DIM = 75; - public const UNSET_OBJ = 76; - public const FE_RESET_R = 77; - public const FE_FETCH_R = 78; - public const EXIT = 79; - public const FETCH_R = 80; - public const FETCH_DIM_R = 81; - public const FETCH_OBJ_R = 82; - public const FETCH_W = 83; - public const FETCH_DIM_W = 84; - public const FETCH_OBJ_W = 85; - public const FETCH_RW = 86; - public const FETCH_DIM_RW = 87; - public const FETCH_OBJ_RW = 88; - public const FETCH_IS = 89; - public const FETCH_DIM_IS = 90; - public const FETCH_OBJ_IS = 91; - public const FETCH_FUNC_ARG = 92; - public const FETCH_DIM_FUNC_ARG = 93; - public const FETCH_OBJ_FUNC_ARG = 94; - public const FETCH_UNSET = 95; - public const FETCH_DIM_UNSET = 96; - public const FETCH_OBJ_UNSET = 97; - public const FETCH_LIST_R = 98; - public const FETCH_CONSTANT = 99; - public const CHECK_FUNC_ARG = 100; - public const EXT_STMT = 101; - public const EXT_FCALL_BEGIN = 102; - public const EXT_FCALL_END = 103; - public const EXT_NOP = 104; - public const TICKS = 105; - public const SEND_VAR_NO_REF = 106; - public const CATCH = 107; - public const THROW = 108; - public const FETCH_CLASS = 109; - public const CLONE = 110; - public const RETURN_BY_REF = 111; - public const INIT_METHOD_CALL = 112; - public const INIT_STATIC_METHOD_CALL = 113; - public const ISSET_ISEMPTY_VAR = 114; - public const ISSET_ISEMPTY_DIM_OBJ = 115; - public const SEND_VAL_EX = 116; - public const SEND_VAR = 117; - public const INIT_USER_CALL = 118; - public const SEND_ARRAY = 119; - public const SEND_USER = 120; - public const STRLEN = 121; - public const DEFINED = 122; - public const TYPE_CHECK = 123; - public const VERIFY_RETURN_TYPE = 124; - public const FE_RESET_RW = 125; - public const FE_FETCH_RW = 126; - public const FE_FREE = 127; - public const INIT_DYNAMIC_CALL = 128; - public const DO_ICALL = 129; - public const DO_UCALL = 130; - public const DO_FCALL_BY_NAME = 131; - public const PRE_INC_OBJ = 132; - public const PRE_DEC_OBJ = 133; - public const POST_INC_OBJ = 134; - public const POST_DEC_OBJ = 135; - public const ECHO = 136; - public const OP_DATA = 137; - public const INSTANCEOF = 138; - public const GENERATOR_CREATE = 139; - public const MAKE_REF = 140; - public const DECLARE_FUNCTION = 141; - public const DECLARE_LAMBDA_FUNCTION = 142; - public const DECLARE_CONST = 143; - public const DECLARE_CLASS = 144; - public const DECLARE_CLASS_DELAYED = 145; - public const DECLARE_ANON_CLASS = 146; - public const ADD_ARRAY_UNPACK = 147; - public const ISSET_ISEMPTY_PROP_OBJ = 148; - public const HANDLE_EXCEPTION = 149; - public const USER_OPCODE = 150; - public const ASSERT_CHECK = 151; - public const JMP_SET = 152; - public const UNSET_CV = 153; - public const ISSET_ISEMPTY_CV = 154; - public const FETCH_LIST_W = 155; - public const SEPARATE = 156; - public const FETCH_CLASS_NAME = 157; - public const CALL_TRAMPOLINE = 158; - public const DISCARD_EXCEPTION = 159; - public const YIELD = 160; - public const GENERATOR_RETURN = 161; - public const FAST_CALL = 162; - public const FAST_RET = 163; - public const RECV_VARIADIC = 164; - public const SEND_UNPACK = 165; - public const YIELD_FROM = 166; - public const COPY_TMP = 167; - public const BIND_GLOBAL = 168; - public const COALESCE = 169; - public const SPACESHIP = 170; - public const FUNC_NUM_ARGS = 171; - public const FUNC_GET_ARGS = 172; - public const FETCH_STATIC_PROP_R = 173; - public const FETCH_STATIC_PROP_W = 174; - public const FETCH_STATIC_PROP_RW = 175; - public const FETCH_STATIC_PROP_IS = 176; - public const FETCH_STATIC_PROP_FUNC_ARG = 177; - public const FETCH_STATIC_PROP_UNSET = 178; - public const UNSET_STATIC_PROP = 179; - public const ISSET_ISEMPTY_STATIC_PROP = 180; - public const FETCH_CLASS_CONSTANT = 181; - public const BIND_LEXICAL = 182; - public const BIND_STATIC = 183; - public const FETCH_THIS = 184; - public const SEND_FUNC_ARG = 185; - public const ISSET_ISEMPTY_THIS = 186; - public const SWITCH_LONG = 187; - public const SWITCH_STRING = 188; - public const IN_ARRAY = 189; - public const COUNT = 190; - public const GET_CLASS = 191; - public const GET_CALLED_CLASS = 192; - public const GET_TYPE = 193; - public const ARRAY_KEY_EXIST = 194; - public const MATCH = 195; - public const CASE_STRICT = 196; - public const MATCH_ERROR = 197; - public const JMP_NULL = 198; - public const CHECK_UNDEF_ARGS = 199; + public const ADD = Defines::ZEND_ADD; + public const SUB = Defines::ZEND_SUB; + public const MUL = Defines::ZEND_MUL; + public const DIV = Defines::ZEND_DIV; + public const MOD = Defines::ZEND_MOD; + public const SL = Defines::ZEND_SL; + public const SR = Defines::ZEND_SR; + public const CONCAT = Defines::ZEND_CONCAT; + public const BW_OR = Defines::ZEND_BW_OR; + public const BW_AND = Defines::ZEND_BW_AND; + public const BW_XOR = Defines::ZEND_BW_XOR; + public const POW = Defines::ZEND_POW; + public const BW_NOT = Defines::ZEND_BW_NOT; + public const BOOL_NOT = Defines::ZEND_BOOL_NOT; + public const BOOL_XOR = Defines::ZEND_BOOL_XOR; + public const IS_IDENTICAL = Defines::ZEND_IS_IDENTICAL; + public const IS_NOT_IDENTICAL = Defines::ZEND_IS_NOT_IDENTICAL; + public const IS_EQUAL = Defines::ZEND_IS_EQUAL; + public const IS_NOT_EQUAL = Defines::ZEND_IS_NOT_EQUAL; + public const IS_SMALLER = Defines::ZEND_IS_SMALLER; + public const IS_SMALLER_OR_EQUAL = Defines::ZEND_IS_SMALLER_OR_EQUAL; + public const ASSIGN = Defines::ZEND_ASSIGN; + public const ASSIGN_DIM = Defines::ZEND_ASSIGN_DIM; + public const ASSIGN_OBJ = Defines::ZEND_ASSIGN_OBJ; + public const ASSIGN_STATIC_PROP = Defines::ZEND_ASSIGN_STATIC_PROP; + public const ASSIGN_OP = Defines::ZEND_ASSIGN_OP; + public const ASSIGN_DIM_OP = Defines::ZEND_ASSIGN_DIM_OP; + public const ASSIGN_OBJ_OP = Defines::ZEND_ASSIGN_OBJ_OP; + public const ASSIGN_STATIC_PROP_OP = Defines::ZEND_ASSIGN_STATIC_PROP_OP; + public const ASSIGN_REF = Defines::ZEND_ASSIGN_REF; + public const QM_ASSIGN = Defines::ZEND_QM_ASSIGN; + public const ASSIGN_OBJ_REF = Defines::ZEND_ASSIGN_OBJ_REF; + public const ASSIGN_STATIC_PROP_REF = Defines::ZEND_ASSIGN_STATIC_PROP_REF; + public const PRE_INC = Defines::ZEND_PRE_INC; + public const PRE_DEC = Defines::ZEND_PRE_DEC; + public const POST_INC = Defines::ZEND_POST_INC; + public const POST_DEC = Defines::ZEND_POST_DEC; + public const PRE_INC_STATIC_PROP = Defines::ZEND_PRE_INC_STATIC_PROP; + public const PRE_DEC_STATIC_PROP = Defines::ZEND_PRE_DEC_STATIC_PROP; + public const POST_INC_STATIC_PROP = Defines::ZEND_POST_INC_STATIC_PROP; + public const POST_DEC_STATIC_PROP = Defines::ZEND_POST_DEC_STATIC_PROP; + public const JMP = Defines::ZEND_JMP; + public const JMPZ = Defines::ZEND_JMPZ; + public const JMPNZ = Defines::ZEND_JMPNZ; + public const JMPZNZ = Defines::ZEND_JMPZNZ; + public const JMPZ_EX = Defines::ZEND_JMPZ_EX; + public const JMPNZ_EX = Defines::ZEND_JMPNZ_EX; + public const CASE = Defines::ZEND_CASE; + public const CHECK_VAR = Defines::ZEND_CHECK_VAR; + public const SEND_VAR_NO_REF_EX = Defines::ZEND_SEND_VAR_NO_REF_EX; + public const CAST = Defines::ZEND_CAST; + public const BOOL = Defines::ZEND_BOOL; + public const FAST_CONCAT = Defines::ZEND_FAST_CONCAT; + public const ROPE_INIT = Defines::ZEND_ROPE_INIT; + public const ROPE_ADD = Defines::ZEND_ROPE_ADD; + public const ROPE_END = Defines::ZEND_ROPE_END; + public const BEGIN_SILENCE = Defines::ZEND_BEGIN_SILENCE; + public const END_SILENCE = Defines::ZEND_END_SILENCE; + public const INIT_FCALL_BY_NAME = Defines::ZEND_INIT_FCALL_BY_NAME; + public const DO_FCALL = Defines::ZEND_DO_FCALL; + public const INIT_FCALL = Defines::ZEND_INIT_FCALL; + public const RETURN = Defines::ZEND_RETURN; + public const RECV = Defines::ZEND_RECV; + public const RECV_INIT = Defines::ZEND_RECV_INIT; + public const SEND_VAL = Defines::ZEND_SEND_VAL; + public const SEND_VAR_EX = Defines::ZEND_SEND_VAR_EX; + public const SEND_REF = Defines::ZEND_SEND_REF; + public const NEW = Defines::ZEND_NEW; + public const INIT_NS_FCALL_BY_NAME = Defines::ZEND_INIT_NS_FCALL_BY_NAME; + public const FREE = Defines::ZEND_FREE; + public const INIT_ARRAY = Defines::ZEND_INIT_ARRAY; + public const ADD_ARRAY_ELEMENT = Defines::ZEND_ADD_ARRAY_ELEMENT; + public const INCLUDE_OR_EVAL = Defines::ZEND_INCLUDE_OR_EVAL; + public const UNSET_VAR = Defines::ZEND_UNSET_VAR; + public const UNSET_DIM = Defines::ZEND_UNSET_DIM; + public const UNSET_OBJ = Defines::ZEND_UNSET_OBJ; + public const FE_RESET_R = Defines::ZEND_FE_RESET_R; + public const FE_FETCH_R = Defines::ZEND_FE_FETCH_R; + public const EXIT = Defines::ZEND_EXIT; + public const FETCH_R = Defines::ZEND_FETCH_R; + public const FETCH_DIM_R = Defines::ZEND_FETCH_DIM_R; + public const FETCH_OBJ_R = Defines::ZEND_FETCH_OBJ_R; + public const FETCH_W = Defines::ZEND_FETCH_W; + public const FETCH_DIM_W = Defines::ZEND_FETCH_DIM_W; + public const FETCH_OBJ_W = Defines::ZEND_FETCH_OBJ_W; + public const FETCH_RW = Defines::ZEND_FETCH_RW; + public const FETCH_DIM_RW = Defines::ZEND_FETCH_DIM_RW; + public const FETCH_OBJ_RW = Defines::ZEND_FETCH_OBJ_RW; + public const FETCH_IS = Defines::ZEND_FETCH_IS; + public const FETCH_DIM_IS = Defines::ZEND_FETCH_DIM_IS; + public const FETCH_OBJ_IS = Defines::ZEND_FETCH_OBJ_IS; + public const FETCH_FUNC_ARG = Defines::ZEND_FETCH_FUNC_ARG; + public const FETCH_DIM_FUNC_ARG = Defines::ZEND_FETCH_DIM_FUNC_ARG; + public const FETCH_OBJ_FUNC_ARG = Defines::ZEND_FETCH_OBJ_FUNC_ARG; + public const FETCH_UNSET = Defines::ZEND_FETCH_UNSET; + public const FETCH_DIM_UNSET = Defines::ZEND_FETCH_DIM_UNSET; + public const FETCH_OBJ_UNSET = Defines::ZEND_FETCH_OBJ_UNSET; + public const FETCH_LIST_R = Defines::ZEND_FETCH_LIST_R; + public const FETCH_CONSTANT = Defines::ZEND_FETCH_CONSTANT; + public const CHECK_FUNC_ARG = Defines::ZEND_CHECK_FUNC_ARG; + public const EXT_STMT = Defines::ZEND_EXT_STMT; + public const EXT_FCALL_BEGIN = Defines::ZEND_EXT_FCALL_BEGIN; + public const EXT_FCALL_END = Defines::ZEND_EXT_FCALL_END; + public const EXT_NOP = Defines::ZEND_EXT_NOP; + public const TICKS = Defines::ZEND_TICKS; + public const SEND_VAR_NO_REF = Defines::ZEND_SEND_VAR_NO_REF; + public const CATCH = Defines::ZEND_CATCH; + public const THROW = Defines::ZEND_THROW; + public const FETCH_CLASS = Defines::ZEND_FETCH_CLASS; + public const CLONE = Defines::ZEND_CLONE; + public const RETURN_BY_REF = Defines::ZEND_RETURN_BY_REF; + public const INIT_METHOD_CALL = Defines::ZEND_INIT_METHOD_CALL; + public const INIT_STATIC_METHOD_CALL = Defines::ZEND_INIT_STATIC_METHOD_CALL; + public const ISSET_ISEMPTY_VAR = Defines::ZEND_ISSET_ISEMPTY_VAR; + public const ISSET_ISEMPTY_DIM_OBJ = Defines::ZEND_ISSET_ISEMPTY_DIM_OBJ; + public const SEND_VAL_EX = Defines::ZEND_SEND_VAL_EX; + public const SEND_VAR = Defines::ZEND_SEND_VAR; + public const INIT_USER_CALL = Defines::ZEND_INIT_USER_CALL; + public const SEND_ARRAY = Defines::ZEND_SEND_ARRAY; + public const SEND_USER = Defines::ZEND_SEND_USER; + public const STRLEN = Defines::ZEND_STRLEN; + public const DEFINED = Defines::ZEND_DEFINED; + public const TYPE_CHECK = Defines::ZEND_TYPE_CHECK; + public const VERIFY_RETURN_TYPE = Defines::ZEND_VERIFY_RETURN_TYPE; + public const FE_RESET_RW = Defines::ZEND_FE_RESET_RW; + public const FE_FETCH_RW = Defines::ZEND_FE_FETCH_RW; + public const FE_FREE = Defines::ZEND_FE_FREE; + public const INIT_DYNAMIC_CALL = Defines::ZEND_INIT_DYNAMIC_CALL; + public const DO_ICALL = Defines::ZEND_DO_ICALL; + public const DO_UCALL = Defines::ZEND_DO_UCALL; + public const DO_FCALL_BY_NAME = Defines::ZEND_DO_FCALL_BY_NAME; + public const PRE_INC_OBJ = Defines::ZEND_PRE_INC_OBJ; + public const PRE_DEC_OBJ = Defines::ZEND_PRE_DEC_OBJ; + public const POST_INC_OBJ = Defines::ZEND_POST_INC_OBJ; + public const POST_DEC_OBJ = Defines::ZEND_POST_DEC_OBJ; + public const ECHO = Defines::ZEND_ECHO; + public const OP_DATA = Defines::ZEND_OP_DATA; + public const INSTANCEOF = Defines::ZEND_INSTANCEOF; + public const GENERATOR_CREATE = Defines::ZEND_GENERATOR_CREATE; + public const MAKE_REF = Defines::ZEND_MAKE_REF; + public const DECLARE_FUNCTION = Defines::ZEND_DECLARE_FUNCTION; + public const DECLARE_LAMBDA_FUNCTION = Defines::ZEND_DECLARE_LAMBDA_FUNCTION; + public const DECLARE_CONST = Defines::ZEND_DECLARE_CONST; + public const DECLARE_CLASS = Defines::ZEND_DECLARE_CLASS; + public const DECLARE_CLASS_DELAYED = Defines::ZEND_DECLARE_CLASS_DELAYED; + public const DECLARE_ANON_CLASS = Defines::ZEND_DECLARE_ANON_CLASS; + public const ADD_ARRAY_UNPACK = Defines::ZEND_ADD_ARRAY_UNPACK; + public const ISSET_ISEMPTY_PROP_OBJ = Defines::ZEND_ISSET_ISEMPTY_PROP_OBJ; + public const HANDLE_EXCEPTION = Defines::ZEND_HANDLE_EXCEPTION; + public const USER_OPCODE = Defines::ZEND_USER_OPCODE; + public const ASSERT_CHECK = Defines::ZEND_ASSERT_CHECK; + public const JMP_SET = Defines::ZEND_JMP_SET; + public const UNSET_CV = Defines::ZEND_UNSET_CV; + public const ISSET_ISEMPTY_CV = Defines::ZEND_ISSET_ISEMPTY_CV; + public const FETCH_LIST_W = Defines::ZEND_FETCH_LIST_W; + public const SEPARATE = Defines::ZEND_SEPARATE; + public const FETCH_CLASS_NAME = Defines::ZEND_FETCH_CLASS_NAME; + public const CALL_TRAMPOLINE = Defines::ZEND_CALL_TRAMPOLINE; + public const DISCARD_EXCEPTION = Defines::ZEND_DISCARD_EXCEPTION; + public const YIELD = Defines::ZEND_YIELD; + public const GENERATOR_RETURN = Defines::ZEND_GENERATOR_RETURN; + public const FAST_CALL = Defines::ZEND_FAST_CALL; + public const FAST_RET = Defines::ZEND_FAST_RET; + public const RECV_VARIADIC = Defines::ZEND_RECV_VARIADIC; + public const SEND_UNPACK = Defines::ZEND_SEND_UNPACK; + public const YIELD_FROM = Defines::ZEND_YIELD_FROM; + public const COPY_TMP = Defines::ZEND_COPY_TMP; + public const BIND_GLOBAL = Defines::ZEND_BIND_GLOBAL; + public const COALESCE = Defines::ZEND_COALESCE; + public const SPACESHIP = Defines::ZEND_SPACESHIP; + public const FUNC_NUM_ARGS = Defines::ZEND_FUNC_NUM_ARGS; + public const FUNC_GET_ARGS = Defines::ZEND_FUNC_GET_ARGS; + public const FETCH_STATIC_PROP_R = Defines::ZEND_FETCH_STATIC_PROP_R; + public const FETCH_STATIC_PROP_W = Defines::ZEND_FETCH_STATIC_PROP_W; + public const FETCH_STATIC_PROP_RW = Defines::ZEND_FETCH_STATIC_PROP_RW; + public const FETCH_STATIC_PROP_IS = Defines::ZEND_FETCH_STATIC_PROP_IS; + public const FETCH_STATIC_PROP_FUNC_ARG = Defines::ZEND_FETCH_STATIC_PROP_FUNC_ARG; + public const FETCH_STATIC_PROP_UNSET = Defines::ZEND_FETCH_STATIC_PROP_UNSET; + public const UNSET_STATIC_PROP = Defines::ZEND_UNSET_STATIC_PROP; + public const ISSET_ISEMPTY_STATIC_PROP = Defines::ZEND_ISSET_ISEMPTY_STATIC_PROP; + public const FETCH_CLASS_CONSTANT = Defines::ZEND_FETCH_CLASS_CONSTANT; + public const BIND_LEXICAL = Defines::ZEND_BIND_LEXICAL; + public const BIND_STATIC = Defines::ZEND_BIND_STATIC; + public const FETCH_THIS = Defines::ZEND_FETCH_THIS; + public const SEND_FUNC_ARG = Defines::ZEND_SEND_FUNC_ARG; + public const ISSET_ISEMPTY_THIS = Defines::ZEND_ISSET_ISEMPTY_THIS; + public const SWITCH_LONG = Defines::ZEND_SWITCH_LONG; + public const SWITCH_STRING = Defines::ZEND_SWITCH_STRING; + public const IN_ARRAY = Defines::ZEND_IN_ARRAY; + public const COUNT = Defines::ZEND_COUNT; + public const GET_CLASS = Defines::ZEND_GET_CLASS; + public const GET_CALLED_CLASS = Defines::ZEND_GET_CALLED_CLASS; + public const GET_TYPE = Defines::ZEND_GET_TYPE; + public const ARRAY_KEY_EXIST = Defines::ZEND_ARRAY_KEY_EXISTS; + public const MATCH = Defines::ZEND_MATCH; + public const CASE_STRICT = Defines::ZEND_CASE_STRICT; + public const MATCH_ERROR = Defines::ZEND_MATCH_ERROR; + public const JMP_NULL = Defines::ZEND_JMP_NULL; + public const CHECK_UNDEF_ARGS = Defines::ZEND_CHECK_UNDEF_ARGS; /** * Reversed class constants, containing names by number diff --git a/src/Type/HashTable.php b/src/Type/HashTable.php index d846c39..308637c 100644 --- a/src/Type/HashTable.php +++ b/src/Type/HashTable.php @@ -15,6 +15,7 @@ use FFI\CData; use IteratorAggregate; use Traversable; +use ZEngine\Constants\Defines; use ZEngine\Core; use ZEngine\Reflection\ReflectionValue; @@ -46,11 +47,11 @@ class HashTable implements IteratorAggregate, ReferenceCountedInterface { use ReferenceCountedTrait; - private const HASH_UPDATE = (1 << 0); - private const HASH_ADD = (1 << 1); - private const HASH_UPDATE_INDIRECT = (1 << 2); - private const HASH_ADD_NEW = (1 << 3); - private const HASH_ADD_NEXT = (1 << 4); + private const HASH_UPDATE = Defines::HASH_UPDATE; + private const HASH_ADD = Defines::HASH_ADD; + private const HASH_UPDATE_INDIRECT = Defines::HASH_UPDATE_INDIRECT; + private const HASH_ADD_NEW = Defines::HASH_ADD_NEW; + private const HASH_ADD_NEXT = Defines::HASH_ADD_NEXT; private CData $pointer; @@ -64,7 +65,7 @@ public function __construct(CData $hashInstance) * * @return Traversable An instance of an object implementing Iterator or Traversable */ - public function getIterator() + public function getIterator(): Traversable { $iterator = function () { $index = 0; diff --git a/src/Type/OpLine.php b/src/Type/OpLine.php index 4df94b9..c270ae8 100644 --- a/src/Type/OpLine.php +++ b/src/Type/OpLine.php @@ -13,6 +13,7 @@ namespace ZEngine\Type; use FFI\CData; +use ZEngine\Constants\Defines; use ZEngine\Core; use ZEngine\Reflection\ReflectionValue; use ZEngine\System\ExecutionData; @@ -39,14 +40,14 @@ class OpLine /** * Unused operand */ - public const IS_UNUSED = 0; + public const IS_UNUSED = Defines::IS_UNUSED; /** * This opcode node type is used for literal values in PHP code. * * For example, the integer literal 1 or string literal 'Hello, World!' will both be of this type. */ - public const IS_CONST = (1<<0); + public const IS_CONST = Defines::IS_CONST; /** * This opcode node type is used for temporary variables. @@ -57,7 +58,7 @@ class OpLine * * For example, the return value of $a++ will be of this type. */ - public const IS_TMP_VAR = (1<<1); + public const IS_TMP_VAR = Defines::IS_TMP_VAR; /** * This opcode node type is used for complex variables in PHP code. @@ -65,7 +66,7 @@ class OpLine * For example, the variable $obj->a is considered to be a complex variable, however the variable $a is not * (it is instead an IS_CV type). */ - public const IS_VAR = (1<<2); + public const IS_VAR = Defines::IS_VAR; /** * This opcode node type is used for simple variables in PHP code. @@ -73,7 +74,7 @@ class OpLine * For example, the variable $a is considered to be a simple variable, * however the variable $obj->a is not (it is instead an IS_VAR type). */ - public const IS_CV = (1<<3); + public const IS_CV = Defines::IS_CV; /** * Execution context (if present). diff --git a/src/Type/ReferenceCountedInterface.php b/src/Type/ReferenceCountedInterface.php index a9a6d37..3876f4c 100644 --- a/src/Type/ReferenceCountedInterface.php +++ b/src/Type/ReferenceCountedInterface.php @@ -12,16 +12,18 @@ namespace ZEngine\Type; +use ZEngine\Constants\Defines; + /** * Interface for all refcounted entries */ interface ReferenceCountedInterface { - public const GC_COLLECTABLE = (1 << 4); - public const GC_PROTECTED = (1 << 5); // used for recursion detection - public const GC_IMMUTABLE = (1 << 6); // can't be canged in place - public const GC_PERSISTENT = (1 << 7); // allocated using malloc - public const GC_PERSISTENT_LOCAL = (1 << 8); // persistent, but thread-local +// public const GC_NOT_COLLECTABLE = Defines::GC_NOT_COLLECTABLE; + public const GC_PROTECTED = Defines::GC_PROTECTED; // used for recursion detection + public const GC_IMMUTABLE = Defines::GC_IMMUTABLE; // can't be canged in place + public const GC_PERSISTENT = Defines::GC_PERSISTENT; // allocated using malloc + public const GC_PERSISTENT_LOCAL = Defines::GC_PERSISTENT_LOCAL; // persistent, but thread-local /** * Returns an internal reference counter value diff --git a/tests/Reflection/ReflectionFunctionTest.php b/tests/Reflection/ReflectionFunctionTest.php index 27f1ef9..e2ff9e6 100644 --- a/tests/Reflection/ReflectionFunctionTest.php +++ b/tests/Reflection/ReflectionFunctionTest.php @@ -45,9 +45,9 @@ public function testSetInternalFunctionDeprecated(): void $refFunction = new ReflectionFunction('var_dump'); $refFunction->setDeprecated(); $this->assertTrue($refFunction->isDeprecated()); - - $this->expectException(Deprecated::class); - $this->expectExceptionMessageMatches('/Function var_dump\(\) is deprecated/'); + $this->expectDeprecation(); +// $this->expectException(Deprecated::class); +// $this->expectExceptionMessageMatches('/Function var_dump\(\) is deprecated/'); var_dump($currentReporting); } finally { error_reporting($currentReporting); From 280eea3e685d10b200843f5f1220ab63db927499 Mon Sep 17 00:00:00 2001 From: Katie Volz Date: Thu, 3 Feb 2022 22:46:34 -0500 Subject: [PATCH 3/5] Fix typo --- src/AbstractSyntaxTree/NodeFactory.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/AbstractSyntaxTree/NodeFactory.php b/src/AbstractSyntaxTree/NodeFactory.php index 36d0f52..3e2e9c7 100644 --- a/src/AbstractSyntaxTree/NodeFactory.php +++ b/src/AbstractSyntaxTree/NodeFactory.php @@ -33,8 +33,7 @@ public static function fromCData(CData $node): NodeInterface $kind = $node->kind; switch (true) { // There are special node types ZVAL, CONSTANT, ZNODE -// case $kind === NodeKind::AST_ZVAL: - case $kind === _zend_ast_kind::ZEND_AST_ZVAL()->value : + case $kind === NodeKind::AST_ZVAL: $node = Core::cast('zend_ast_zval *', $node); return ValueNode::fromCData($node); case $kind === NodeKind::AST_CONSTANT: From cfca9a5adbe4ce702ee9d6bc5b22dc3917b90bc8 Mon Sep 17 00:00:00 2001 From: Katie Volz Date: Mon, 21 Mar 2022 16:23:41 -0400 Subject: [PATCH 4/5] Properly handle multiple init calls --- src/Core.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core.php b/src/Core.php index f4a6698..2a4180e 100644 --- a/src/Core.php +++ b/src/Core.php @@ -237,7 +237,7 @@ public static function init() throw new \RuntimeException('Preload mode requires that you call Core::preload before'); } // If not, then load definitions by hand - $definition = require_once __DIR__ . "/../include/engine.php"; + $definition = require __DIR__ . "/../include/engine.php"; $arguments = [$definition]; // For Windows platform we should load symbols from the shared php7.dll library From cfbbb097e1789279577591c24ea210d888ceb38c Mon Sep 17 00:00:00 2001 From: Katie Volz Date: Mon, 21 Mar 2022 16:23:53 -0400 Subject: [PATCH 5/5] Fix operation handlers --- src/Reflection/ReflectionClass.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Reflection/ReflectionClass.php b/src/Reflection/ReflectionClass.php index 839f696..9e4c59d 100644 --- a/src/Reflection/ReflectionClass.php +++ b/src/Reflection/ReflectionClass.php @@ -888,7 +888,7 @@ public static function newInstanceRaw(CData $classType, bool $persistent = false $objectSize = Core::sizeof(Core::type('zend_object')); $totalSize = $objectSize + self::getObjectPropertiesSize($classType); $memory = Core::new("char[{$totalSize}]", false, $persistent); - $object = Core::cast('zend_object *', $memory); + $object = Core::cast('zend_object *', Core::addr($memory)); Core::call('zend_object_std_init', $object, $classType); $object->handlers = self::getObjectHandlers($classType);