Skip to content

Commit 5397d84

Browse files
committed
Zend: Remove dependency on zend.h for certain headers
Allows to move AST definitions out from zend_compile.h and into zend_ast.h
1 parent 8f8f31a commit 5397d84

7 files changed

+54
-45
lines changed

Zend/zend_alloc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include <stdio.h>
2525

2626
#include "../TSRM/TSRM.h"
27-
#include "zend.h"
2827

2928
#ifndef ZEND_MM_ALIGNMENT
3029
# error "ZEND_MM_ALIGNMENT was not defined during configure"

Zend/zend_ast.h

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#ifndef ZEND_AST_H
2222
#define ZEND_AST_H
2323

24-
#include "zend.h"
24+
#include "zend_types.h"
2525

2626
#ifndef ZEND_AST_SPEC
2727
# define ZEND_AST_SPEC 1
@@ -213,6 +213,37 @@ typedef struct _zend_ast_decl {
213213
zend_ast *child[5];
214214
} zend_ast_decl;
215215

216+
typedef union _znode_op {
217+
uint32_t constant;
218+
uint32_t var;
219+
uint32_t num;
220+
uint32_t opline_num; /* Needs to be signed */
221+
#if ZEND_USE_ABS_JMP_ADDR
222+
zend_op *jmp_addr;
223+
#else
224+
uint32_t jmp_offset;
225+
#endif
226+
#if ZEND_USE_ABS_CONST_ADDR
227+
zval *zv;
228+
#endif
229+
} znode_op;
230+
231+
typedef struct _znode { /* used only during compilation */
232+
uint8_t op_type;
233+
uint8_t flag;
234+
union {
235+
znode_op op;
236+
zval constant; /* replaced by literal/zv */
237+
} u;
238+
} znode;
239+
240+
typedef struct _zend_ast_znode {
241+
zend_ast_kind kind;
242+
zend_ast_attr attr;
243+
uint32_t lineno;
244+
znode node;
245+
} zend_ast_znode;
246+
216247
typedef void (*zend_ast_process_t)(zend_ast *ast);
217248
extern ZEND_API zend_ast_process_t zend_ast_process;
218249

@@ -224,6 +255,7 @@ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_from_long(zend_long lval)
224255

225256
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_constant(zend_string *name, zend_ast_attr attr);
226257
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_class_const_or_name(zend_ast *class_name, zend_ast *name);
258+
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_znode(znode *node);
227259

228260
#if ZEND_AST_SPEC
229261
# define ZEND_AST_SPEC_CALL(name, ...) \
@@ -360,6 +392,10 @@ static zend_always_inline uint32_t zend_ast_get_lineno(zend_ast *ast) {
360392
}
361393
}
362394

395+
static zend_always_inline znode *zend_ast_get_znode(zend_ast *ast) {
396+
return &((zend_ast_znode *) ast)->node;
397+
}
398+
363399
static zend_always_inline zend_ast *zend_ast_create_binary_op(uint32_t opcode, zend_ast *op0, zend_ast *op1) {
364400
return zend_ast_create_ex(ZEND_AST_BINARY_OP, opcode, op0, op1);
365401
}

Zend/zend_compile.h

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@
2020
#ifndef ZEND_COMPILE_H
2121
#define ZEND_COMPILE_H
2222

23-
#include "zend.h"
2423
#include "zend_ast.h"
24+
#include "zend_types.h"
25+
#include "zend_map_ptr.h"
26+
#include "zend_alloc.h"
2527

2628
#include <stdarg.h>
2729
#include <stdint.h>
@@ -61,44 +63,6 @@ typedef struct _zend_op zend_op;
6163
# define ZEND_USE_ABS_CONST_ADDR 0
6264
#endif
6365

64-
typedef union _znode_op {
65-
uint32_t constant;
66-
uint32_t var;
67-
uint32_t num;
68-
uint32_t opline_num; /* Needs to be signed */
69-
#if ZEND_USE_ABS_JMP_ADDR
70-
zend_op *jmp_addr;
71-
#else
72-
uint32_t jmp_offset;
73-
#endif
74-
#if ZEND_USE_ABS_CONST_ADDR
75-
zval *zv;
76-
#endif
77-
} znode_op;
78-
79-
typedef struct _znode { /* used only during compilation */
80-
uint8_t op_type;
81-
uint8_t flag;
82-
union {
83-
znode_op op;
84-
zval constant; /* replaced by literal/zv */
85-
} u;
86-
} znode;
87-
88-
/* Temporarily defined here, to avoid header ordering issues */
89-
typedef struct _zend_ast_znode {
90-
zend_ast_kind kind;
91-
zend_ast_attr attr;
92-
uint32_t lineno;
93-
znode node;
94-
} zend_ast_znode;
95-
96-
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_znode(znode *node);
97-
98-
static zend_always_inline znode *zend_ast_get_znode(zend_ast *ast) {
99-
return &((zend_ast_znode *) ast)->node;
100-
}
101-
10266
typedef struct _zend_declarables {
10367
zend_long ticks;
10468
} zend_declarables;
@@ -492,6 +456,9 @@ struct _zend_op_array {
492456
#define ZEND_RETURN_VALUE 0
493457
#define ZEND_RETURN_REFERENCE 1
494458

459+
#define INTERNAL_FUNCTION_PARAMETERS zend_execute_data *execute_data, zval *return_value
460+
#define INTERNAL_FUNCTION_PARAM_PASSTHRU execute_data, return_value
461+
495462
/* zend_internal_function_handler */
496463
typedef void (ZEND_FASTCALL *zif_handler)(INTERNAL_FUNCTION_PARAMETERS);
497464

Zend/zend_hash.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
#ifndef ZEND_HASH_H
2222
#define ZEND_HASH_H
2323

24-
#include "zend.h"
24+
#include "zend_types.h"
25+
#include "zend_gc.h"
26+
#include "zend_string.h"
2527
#include "zend_sort.h"
2628

2729
#define HASH_KEY_IS_STRING 1

Zend/zend_objects_API.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@
2020
#ifndef ZEND_OBJECTS_API_H
2121
#define ZEND_OBJECTS_API_H
2222

23-
#include "zend.h"
24-
#include "zend_compile.h"
23+
#include "zend_types.h"
24+
#include "zend_gc.h"
25+
#include "zend_alloc.h"
26+
#include "zend_compile.h" /* For zend_property_info */
2527

2628
#define OBJ_BUCKET_INVALID (1<<0)
2729

Zend/zend_string.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
#ifndef ZEND_STRING_H
2020
#define ZEND_STRING_H
2121

22-
#include "zend.h"
22+
#include "zend_types.h"
23+
#include "zend_gc.h"
24+
#include "zend_alloc.h"
2325

2426
BEGIN_EXTERN_C()
2527

Zend/zend_variables.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include "zend_types.h"
2525
#include "zend_gc.h"
26+
#include "zend_hash.h"
2627

2728
BEGIN_EXTERN_C()
2829

0 commit comments

Comments
 (0)