1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
diff --git parsekit.c parsekit.c
index cfc45e7..5ddd3a7 100644
--- parsekit.c
+++ parsekit.c
@@ -78,18 +78,18 @@ static void php_parsekit_parse_node(zval *return_value, zend_op_array *op_array,
#ifdef IS_CV
/* PHP >= 5.1 */
} else if (node->op_type == IS_CV) {
- add_assoc_long(return_value, "var", node->u.var);
- add_assoc_stringl(return_value, "varname", op_array->vars[node->u.var].name, op_array->vars[node->u.var].name_len, 1);
+ add_assoc_long(return_value, "var", node->u.op.var);
+ add_assoc_stringl(return_value, "varname", op_array->vars[node->u.op.var].name, op_array->vars[node->u.op.var].name_len, 1);
#endif
} else {
/* IS_VAR || IS_TMP_VAR || IS_UNUSED */
char sop[(sizeof(void *) * 2) + 1];
- snprintf(sop, (sizeof(void *) * 2) + 1, "%X", (unsigned int)node->u.var);
+ snprintf(sop, (sizeof(void *) * 2) + 1, "%X", (unsigned int)node->u.op.var);
if ((flags & PHP_PARSEKIT_VAR) ||
(options & PHP_PARSEKIT_ALL_ELEMENTS)) {
- add_assoc_long(return_value, "var", node->u.var / sizeof(temp_variable));
+ add_assoc_long(return_value, "var", node->u.op.var / sizeof(temp_variable));
} else if (options & PHP_PARSEKIT_ALWAYS_SET) {
add_assoc_null(return_value, "var");
}
@@ -114,7 +114,7 @@ static void php_parsekit_parse_node(zval *return_value, zend_op_array *op_array,
(options & PHP_PARSEKIT_ALL_ELEMENTS)) {
add_assoc_string(return_value, "jmp_addr", sop, 1);
snprintf(sop, sizeof(sop)-1, "%u",
- ((unsigned int)((char*)node->u.var - (char*)op_array->opcodes))/sizeof(zend_op));
+ ((unsigned int)((char*)node->u.op.var - (char*)op_array->opcodes))/sizeof(zend_op));
add_assoc_string(return_value, "jmp_offset", sop, 1);
} else if (options & PHP_PARSEKIT_ALWAYS_SET) {
add_assoc_null(return_value, "jmp_addr");
@@ -123,9 +123,9 @@ static void php_parsekit_parse_node(zval *return_value, zend_op_array *op_array,
if ((flags & PHP_PARSEKIT_EA_TYPE) ||
(options & PHP_PARSEKIT_ALL_ELEMENTS)) {
- add_assoc_long(return_value, "EA.type", node->u.EA.type);
+ add_assoc_long(return_value, "EA", node->EA);
} else if (options & PHP_PARSEKIT_ALWAYS_SET) {
- add_assoc_null(return_value, "EA.type");
+ add_assoc_null(return_value, "EA");
}
}
}
@@ -300,7 +300,7 @@ static void php_parsekit_parse_op_array(zval *return_value, zend_op_array *ops,
}
add_assoc_long(return_value, "num_args", ops->num_args);
add_assoc_long(return_value, "required_num_args", ops->required_num_args);
- add_assoc_bool(return_value, "pass_rest_by_reference", ops->pass_rest_by_reference);
+ add_assoc_bool(return_value, "pass_rest_by_reference", ops->fn_flags & ZEND_ACC_PASS_REST_BY_REFERENCE);
if (ops->num_args && ops->arg_info) {
MAKE_STD_ZVAL(tmpzval);
@@ -374,15 +374,15 @@ static void php_parsekit_parse_op_array(zval *return_value, zend_op_array *ops,
#endif
/* ZE1 and ZE2 */
- add_assoc_bool(return_value, "return_reference", ops->return_reference);
+ add_assoc_bool(return_value, "return_reference", ops->fn_flags & ZEND_ACC_RETURN_REFERENCE);
add_assoc_long(return_value, "refcount", *(ops->refcount));
add_assoc_long(return_value, "last", ops->last);
- add_assoc_long(return_value, "size", ops->size);
+ add_assoc_long(return_value, "size", CG(context).opcodes_size);
add_assoc_long(return_value, "T", ops->T);
add_assoc_long(return_value, "last_brk_cont", ops->last_brk_cont);
- add_assoc_long(return_value, "current_brk_cont", ops->current_brk_cont);
- add_assoc_long(return_value, "backpatch_count", ops->backpatch_count);
- add_assoc_bool(return_value, "done_pass_two", ops->done_pass_two);
+ add_assoc_long(return_value, "current_brk_cont", CG(context).current_brk_cont);
+ add_assoc_long(return_value, "backpatch_count", CG(context).backpatch_count);
+ add_assoc_bool(return_value, "done_pass_two", ops->fn_flags & ZEND_ACC_DONE_PASS_TWO);
if (ops->last_brk_cont > 0) {
MAKE_STD_ZVAL(tmpzval);
@@ -413,10 +413,10 @@ static void php_parsekit_parse_op_array(zval *return_value, zend_op_array *ops,
add_assoc_null(return_value, "static_variables");
}
- if (ops->start_op) {
+ if (EG(start_op)) {
char sop[(sizeof(void *) * 2) + 1];
- snprintf(sop, sizeof(sop), "%X", (unsigned int)ops->start_op);
+ snprintf(sop, sizeof(sop), "%X", (unsigned int)EG(start_op));
add_assoc_string(return_value, "start_op", sop, 1);
} else if (options & PHP_PARSEKIT_ALWAYS_SET) {
add_assoc_null(return_value, "start_op");
@@ -431,7 +431,7 @@ static void php_parsekit_parse_op_array(zval *return_value, zend_op_array *ops,
/* Leave this last, it simplifies readability */
MAKE_STD_ZVAL(tmpzval);
array_init(tmpzval);
- for(op = ops->opcodes, i = 0; op && i < ops->size; op++, i++) {
+ for(op = ops->opcodes, i = 0; op && i < CG(context).opcodes_size; op++, i++) {
zval *zop;
MAKE_STD_ZVAL(zop);
@@ -447,17 +447,17 @@ static void php_parsekit_parse_op_array(zval *return_value, zend_op_array *ops,
static int php_parsekit_parse_node_simple(char **pret, zend_op_array *op_array, znode *node, zend_op_array *oparray TSRMLS_DC)
{
if (node->op_type == IS_UNUSED) {
- if (node->u.var) {
+ if (node->u.op.var) {
#ifdef ZEND_ENGINE_2
- if (node->u.jmp_addr >= oparray->opcodes &&
- node->u.jmp_addr <= (oparray->opcodes + (sizeof(zend_op) * oparray->size)))
+ if (node->u.op.jmp_addr >= oparray->opcodes &&
+ node->u.op.jmp_addr <= (oparray->opcodes + (sizeof(zend_op) * CG(context).opcodes_size)))
{
- spprintf(pret, 0, "#%d", node->u.jmp_addr - oparray->opcodes);
+ spprintf(pret, 0, "#%d", node->u.op.jmp_addr - oparray->opcodes);
}
else
#endif
{
- spprintf(pret, 0, "0x%X", node->u.var);
+ spprintf(pret, 0, "0x%X", node->u.op.var);
}
return 1;
} else {
@@ -514,7 +514,7 @@ static int php_parsekit_parse_node_simple(char **pret, zend_op_array *op_array,
}
}
- spprintf(pret, 0, "T(%d)", node->u.var / sizeof(temp_variable));
+ spprintf(pret, 0, "T(%d)", node->u.op.var / sizeof(temp_variable));
return 1;
}
/* }}} */
@@ -528,7 +528,7 @@ static void php_parsekit_parse_op_array_simple(zval *return_value, zend_op_array
array_init(return_value);
- for (op = ops->opcodes, i = 0; op && i < ops->size; op++, i++) {
+ for (op = ops->opcodes, i = 0; op && i < CG(context).opcodes_size; op++, i++) {
char *opline, *result, *op1, *op2;
int opline_len, freeit = 0;
@@ -633,7 +633,7 @@ static int php_parsekit_parse_class_entry(zval *return_value, zend_class_entry *
} else if (options & PHP_PARSEKIT_ALWAYS_SET) {
add_assoc_null(return_value, "parent");
}
- add_assoc_bool(return_value, "constants_updated", ce->constants_updated);
+ add_assoc_bool(return_value, "constants_updated", ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED);
#ifdef ZEND_ENGINE_2
/* ZE2 class_entry members */
add_assoc_long(return_value, "ce_flags", ce->ce_flags);
@@ -691,12 +691,12 @@ static int php_parsekit_parse_class_entry(zval *return_value, zend_class_entry *
add_assoc_null(return_value, "properties_info");
}
- if (ce->static_members && zend_hash_num_elements(ce->static_members) > 0) {
+ if (ce->static_members_table && zend_hash_num_elements(ce->static_members_table) > 0) {
zval *tmp_zval;
MAKE_STD_ZVAL(tmpzval);
array_init(tmpzval);
- zend_hash_copy(HASH_OF(tmpzval), ce->static_members, (copy_ctor_func_t) zval_add_ref, (void *) &tmp_zval, sizeof(zval *));
+ zend_hash_copy(HASH_OF(tmpzval), ce->static_members_table, (copy_ctor_func_t) zval_add_ref, (void *) &tmp_zval, sizeof(zval *));
add_assoc_zval(return_value, "static_members", tmpzval);
} else if (options & PHP_PARSEKIT_ALWAYS_SET) {
add_assoc_null(return_value, "static_members");
@@ -724,11 +724,11 @@ static int php_parsekit_parse_class_entry(zval *return_value, zend_class_entry *
add_assoc_null(return_value, "interfaces");
}
- add_assoc_string(return_value, "filename", ce->filename, 1);
- add_assoc_long(return_value, "line_start", ce->line_start);
- add_assoc_long(return_value, "line_end", ce->line_end);
- if (ce->doc_comment) {
- add_assoc_stringl(return_value, "doc_comment", ce->doc_comment, ce->doc_comment_len, 1);
+ add_assoc_string(return_value, "filename", ce->info.user.filename, 1);
+ add_assoc_long(return_value, "line_start", ce->info.user.line_start);
+ add_assoc_long(return_value, "line_end", ce->info.user.line_end);
+ if (ce->info.user.doc_comment) {
+ add_assoc_stringl(return_value, "doc_comment", ce->info.user.doc_comment, ce->info.user.doc_comment_len, 1);
} else if (options & PHP_PARSEKIT_ALWAYS_SET) {
add_assoc_null(return_value, "doc_comment");
}
@@ -757,12 +757,12 @@ static int php_parsekit_parse_class_entry(zval *return_value, zend_class_entry *
add_assoc_null(return_value, "function_table");
}
- if (zend_hash_num_elements(&(ce->default_properties)) > 0) {
+ if (zend_hash_num_elements(&(ce->default_properties_table)) > 0) {
zval *tmp_zval;
MAKE_STD_ZVAL(tmpzval);
array_init(tmpzval);
- zend_hash_copy(HASH_OF(tmpzval), &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, (void *) &tmp_zval, sizeof(zval *));
+ zend_hash_copy(HASH_OF(tmpzval), &(ce->default_properties_table), (copy_ctor_func_t) zval_add_ref, (void *) &tmp_zval, sizeof(zval *));
add_assoc_zval(return_value, "default_properties", tmpzval);
} else if (options & PHP_PARSEKIT_ALWAYS_SET) {
add_assoc_null(return_value, "default_properties");
@@ -1131,7 +1131,7 @@ static unsigned char php_parsekit_second_arg_force_ref[] = { 3, BYREF_NONE, BYRE
#endif
/* {{{ function_entry */
-function_entry parsekit_functions[] = {
+zend_function_entry parsekit_functions[] = {
PHP_FE(parsekit_compile_string, php_parsekit_second_arg_force_ref)
PHP_FE(parsekit_compile_file, php_parsekit_second_arg_force_ref)
PHP_FE(parsekit_opcode_flags, NULL)
|