| 1 | |
|---|
| 2 | /* {{{ Pre-declare */ |
|---|
| 3 | DECL_STRUCT_P_FUNC(`zval') |
|---|
| 4 | DECL_STRUCT_P_FUNC(`zval_ptr') |
|---|
| 5 | DECL_STRUCT_P_FUNC(`zend_op_array') |
|---|
| 6 | DECL_STRUCT_P_FUNC(`zend_class_entry') |
|---|
| 7 | |
|---|
| 8 | DECL_STRUCT_P_FUNC(`zend_constant') |
|---|
| 9 | |
|---|
| 10 | DECL_STRUCT_P_FUNC(`zend_function') |
|---|
| 11 | DECL_STRUCT_P_FUNC(`xc_entry_t') |
|---|
| 12 | |
|---|
| 13 | DECL_STRUCT_P_FUNC(`zend_property_info') |
|---|
| 14 | |
|---|
| 15 | /* }}} */ |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | DEF_STRUCT_P_FUNC(`zend_compiled_variable', , ` |
|---|
| 20 | DISPATCH(int, name_len) |
|---|
| 21 | PROC_ZSTRING_L(, name, name_len) |
|---|
| 22 | DISPATCH(ulong, hash_value) |
|---|
| 23 | ') |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | DEF_STRUCT_P_FUNC(`zend_uint', , ` |
|---|
| 28 | IFCOPY(`dst[0] = src[0];') |
|---|
| 29 | IFDPRINT(` |
|---|
| 30 | INDENT() |
|---|
| 31 | fprintf(stderr, "%u\n", src[0]); |
|---|
| 32 | ') |
|---|
| 33 | DONE_SIZE(sizeof(src[0])) |
|---|
| 34 | ') |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | DEF_STRUCT_P_FUNC(`int', , ` |
|---|
| 39 | IFCOPY(`*dst = *src;') |
|---|
| 40 | IFDPRINT(` |
|---|
| 41 | INDENT() |
|---|
| 42 | fprintf(stderr, "%d\n", src[0]); |
|---|
| 43 | ') |
|---|
| 44 | DONE_SIZE(sizeof(src[0])) |
|---|
| 45 | ') |
|---|
| 46 | |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | DEF_STRUCT_P_FUNC(`zend_try_catch_element', , ` |
|---|
| 51 | DISPATCH(zend_uint, try_op) |
|---|
| 52 | DISPATCH(zend_uint, catch_op) |
|---|
| 53 | ') |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | DEF_STRUCT_P_FUNC(`zend_brk_cont_element', , ` |
|---|
| 58 | |
|---|
| 59 | DISPATCH(int, start) |
|---|
| 60 | |
|---|
| 61 | DISPATCH(int, cont) |
|---|
| 62 | DISPATCH(int, brk) |
|---|
| 63 | DISPATCH(int, parent) |
|---|
| 64 | ') |
|---|
| 65 | |
|---|
| 66 | DEF_HASH_TABLE_FUNC(`HashTable_zval_ptr', `zval_ptr') |
|---|
| 67 | |
|---|
| 68 | DEF_HASH_TABLE_FUNC(`HashTable_zend_constant', `zend_constant') |
|---|
| 69 | |
|---|
| 70 | DEF_HASH_TABLE_FUNC(`HashTable_zend_function', `zend_function') |
|---|
| 71 | |
|---|
| 72 | DEF_HASH_TABLE_FUNC(`HashTable_zend_property_info', `zend_property_info') |
|---|
| 73 | |
|---|
| 74 | DEF_STRUCT_P_FUNC(`zval', , ` |
|---|
| 75 | IFDASM(`do { |
|---|
| 76 | zval_dtor(dst); |
|---|
| 77 | *dst = *src; |
|---|
| 78 | zval_copy_ctor(dst); |
|---|
| 79 | ZVAL_REFCOUNT(dst) = 1; |
|---|
| 80 | DONE(value) |
|---|
| 81 | DONE(refcount) |
|---|
| 82 | DONE(type) |
|---|
| 83 | DONE(is_ref) |
|---|
| 84 | } while(0); |
|---|
| 85 | return; |
|---|
| 86 | ', ` |
|---|
| 87 | |
|---|
| 88 | /* Variable information */ |
|---|
| 89 | |
|---|
| 90 | DISABLECHECK(` |
|---|
| 91 | switch (src->type & ~IS_CONSTANT_INDEX) { |
|---|
| 92 | case IS_LONG: |
|---|
| 93 | case IS_RESOURCE: |
|---|
| 94 | case IS_BOOL: |
|---|
| 95 | DISPATCH(long, value.lval) |
|---|
| 96 | break; |
|---|
| 97 | case IS_DOUBLE: |
|---|
| 98 | DISPATCH(double, value.dval) |
|---|
| 99 | break; |
|---|
| 100 | case IS_NULL: |
|---|
| 101 | IFDPRINT(`INDENT()`'fprintf(stderr, "\tNULL\n");') |
|---|
| 102 | break; |
|---|
| 103 | |
|---|
| 104 | case IS_CONSTANT: |
|---|
| 105 | |
|---|
| 106 | if (UG(unicode)) { |
|---|
| 107 | goto proc_unicode; |
|---|
| 108 | } |
|---|
| 109 | |
|---|
| 110 | case IS_STRING: |
|---|
| 111 | |
|---|
| 112 | case FLAG_IS_BC: |
|---|
| 113 | |
|---|
| 114 | DISPATCH(int, value.str.len) |
|---|
| 115 | PROC_STRING_L(value.str.val, value.str.len) |
|---|
| 116 | break; |
|---|
| 117 | |
|---|
| 118 | case IS_UNICODE: |
|---|
| 119 | proc_unicode: |
|---|
| 120 | DISPATCH(int32_t, value.uni.len) |
|---|
| 121 | PROC_ZSTRING_L(1, value.uni.val, value.uni.len) |
|---|
| 122 | break; |
|---|
| 123 | |
|---|
| 124 | |
|---|
| 125 | case IS_ARRAY: |
|---|
| 126 | case IS_CONSTANT_ARRAY: |
|---|
| 127 | STRUCT_P(HashTable, value.ht, HashTable_zval_ptr) |
|---|
| 128 | break; |
|---|
| 129 | |
|---|
| 130 | case IS_OBJECT: |
|---|
| 131 | IFNOTMEMCPY(`IFCOPY(`memcpy(dst, src, sizeof(src[0]));')') |
|---|
| 132 | |
|---|
| 133 | |
|---|
| 134 | STRUCT_P(zend_class_entry, value.obj.ce) |
|---|
| 135 | STRUCT_P(HashTable, value.obj.properties, HashTable_zval_ptr) |
|---|
| 136 | |
|---|
| 137 | break; |
|---|
| 138 | |
|---|
| 139 | default: |
|---|
| 140 | assert(0); |
|---|
| 141 | } |
|---|
| 142 | ') |
|---|
| 143 | |
|---|
| 144 | DONE(value) |
|---|
| 145 | DISPATCH(zval_data_type, type) |
|---|
| 146 | DISPATCH(zend_uchar, is_ref) |
|---|
| 147 | DISPATCH(zend_ushort, refcount) |
|---|
| 148 | ') |
|---|
| 149 | ') |
|---|
| 150 | |
|---|
| 151 | DEF_STRUCT_P_FUNC(`zval_ptr', , ` |
|---|
| 152 | IFDASM(` |
|---|
| 153 | pushdefFUNC_NAME(`zval') |
|---|
| 154 | FUNC_NAME (dst, src[0] TSRMLS_CC); |
|---|
| 155 | popdef(`FUNC_NAME') |
|---|
| 156 | ', ` |
|---|
| 157 | do { |
|---|
| 158 | IFCALCCOPY(` |
|---|
| 159 | if (processor->reference) { |
|---|
| 160 | zval_ptr *ppzv; |
|---|
| 161 | if (zend_hash_find(&processor->zvalptrs, (char *) &src[0], sizeof(src[0]), (void **) &ppzv) == SUCCESS) { |
|---|
| 162 | IFCOPY(` |
|---|
| 163 | dst[0] = *ppzv; |
|---|
| 164 | /* *dst is updated */ |
|---|
| 165 | |
|---|
| 166 | ') |
|---|
| 167 | IFSTORE(`assert(xc_is_shm(dst[0]));') |
|---|
| 168 | IFRESTORE(`assert(!xc_is_shm(dst[0]));') |
|---|
| 169 | break; |
|---|
| 170 | } |
|---|
| 171 | } |
|---|
| 172 | ') |
|---|
| 173 | |
|---|
| 174 | ALLOC(dst[0], zval) |
|---|
| 175 | IFCALCCOPY(` |
|---|
| 176 | if (processor->reference) { |
|---|
| 177 | IFCALC(` |
|---|
| 178 | /* make dummy */ |
|---|
| 179 | zval_ptr pzv = (zval_ptr)-1; |
|---|
| 180 | ', ` |
|---|
| 181 | zval_ptr pzv = dst[0]; |
|---|
| 182 | FIXPOINTER_EX(zval, pzv) |
|---|
| 183 | ') |
|---|
| 184 | if (zend_hash_add(&processor->zvalptrs, (char *) &src[0], sizeof(src[0]), (void *) &pzv, sizeof(pzv), NULL) == SUCCESS) { |
|---|
| 185 | /* first add, go on */ |
|---|
| 186 | |
|---|
| 187 | } |
|---|
| 188 | else { |
|---|
| 189 | assert(0); |
|---|
| 190 | } |
|---|
| 191 | } |
|---|
| 192 | ') |
|---|
| 193 | IFCOPY(` |
|---|
| 194 | |
|---|
| 195 | ') |
|---|
| 196 | STRUCT_P_EX(zval, dst[0], src[0], `[0]', `', ` ') |
|---|
| 197 | FIXPOINTER_EX(zval, dst[0]) |
|---|
| 198 | } while (0); |
|---|
| 199 | ') |
|---|
| 200 | DONE_SIZE(sizeof(zval_ptr)) |
|---|
| 201 | ') |
|---|
| 202 | |
|---|
| 203 | |
|---|
| 204 | |
|---|
| 205 | DEF_STRUCT_P_FUNC(`zend_arg_info', , ` |
|---|
| 206 | DISPATCH(zend_uint, name_len) |
|---|
| 207 | PROC_ZSTRING_L(, name, name_len) |
|---|
| 208 | DISPATCH(zend_uint, class_name_len) |
|---|
| 209 | PROC_ZSTRING_L(, class_name, class_name_len) |
|---|
| 210 | DISPATCH(zend_bool, array_type_hint) |
|---|
| 211 | DISPATCH(zend_bool, allow_null) |
|---|
| 212 | DISPATCH(zend_bool, pass_by_reference) |
|---|
| 213 | DISPATCH(zend_bool, return_reference) |
|---|
| 214 | DISPATCH(int, required_num_args) |
|---|
| 215 | ') |
|---|
| 216 | |
|---|
| 217 | |
|---|
| 218 | |
|---|
| 219 | DEF_STRUCT_P_FUNC(`zend_constant', , ` |
|---|
| 220 | STRUCT(zval, value) |
|---|
| 221 | DISPATCH(int, flags) |
|---|
| 222 | DISPATCH(uint, name_len) |
|---|
| 223 | pushdef(`emalloc', `malloc($1)') |
|---|
| 224 | pushdef(`ecalloc', `calloc($1, $2)') |
|---|
| 225 | PROC_ZSTRING_L(, name, name_len) |
|---|
| 226 | popdef(`ecalloc') |
|---|
| 227 | popdef(`emalloc') |
|---|
| 228 | DISPATCH(int, module_number) |
|---|
| 229 | ') |
|---|
| 230 | |
|---|
| 231 | |
|---|
| 232 | DEF_STRUCT_P_FUNC(`zend_function', , ` |
|---|
| 233 | DISABLECHECK(` |
|---|
| 234 | switch (src->type) { |
|---|
| 235 | case ZEND_INTERNAL_FUNCTION: |
|---|
| 236 | case ZEND_OVERLOADED_FUNCTION: |
|---|
| 237 | IFNOTMEMCPY(`IFCOPY(`memcpy(dst, src, sizeof(src[0]));')') |
|---|
| 238 | break; |
|---|
| 239 | |
|---|
| 240 | case ZEND_USER_FUNCTION: |
|---|
| 241 | case ZEND_EVAL_CODE: |
|---|
| 242 | DONE(type) |
|---|
| 243 | STRUCT(zend_op_array, op_array) |
|---|
| 244 | break; |
|---|
| 245 | |
|---|
| 246 | default: |
|---|
| 247 | assert(0); |
|---|
| 248 | } |
|---|
| 249 | ') |
|---|
| 250 | DONE_SIZE(sizeof(src[0])) |
|---|
| 251 | ') |
|---|
| 252 | |
|---|
| 253 | |
|---|
| 254 | |
|---|
| 255 | DEF_STRUCT_P_FUNC(`zend_property_info', , ` |
|---|
| 256 | DISPATCH(zend_uint, flags) |
|---|
| 257 | DISPATCH(int, name_length) |
|---|
| 258 | PROC_ZSTRING_L(, name, name_length) |
|---|
| 259 | DISPATCH(ulong, h) |
|---|
| 260 | |
|---|
| 261 | DISPATCH(int, doc_comment_len) |
|---|
| 262 | PROC_STRING_L(doc_comment, doc_comment_len) |
|---|
| 263 | |
|---|
| 264 | |
|---|
| 265 | |
|---|
| 266 | PROC_CLASS_ENTRY_P(ce) |
|---|
| 267 | |
|---|
| 268 | ') |
|---|
| 269 | |
|---|
| 270 | |
|---|
| 271 | DEF_STRUCT_P_FUNC(`zend_class_entry', , ` |
|---|
| 272 | IFCOPY(` |
|---|
| 273 | processor->active_class_entry_src = src; |
|---|
| 274 | processor->active_class_entry_dst = dst; |
|---|
| 275 | ') |
|---|
| 276 | DISPATCH(char, type) |
|---|
| 277 | DISPATCH(zend_uint, name_length) |
|---|
| 278 | PROC_ZSTRING_L(, name, name_length) |
|---|
| 279 | IFRESTORE(` |
|---|
| 280 | |
|---|
| 281 | /* just copy parent and resolve on install_class */ |
|---|
| 282 | COPY(parent) |
|---|
| 283 | |
|---|
| 284 | PROC_CLASS_ENTRY_P(parent) |
|---|
| 285 | |
|---|
| 286 | ', ` |
|---|
| 287 | PROC_CLASS_ENTRY_P(parent) |
|---|
| 288 | ') |
|---|
| 289 | |
|---|
| 290 | DISPATCH(int, refcount) |
|---|
| 291 | |
|---|
| 292 | STRUCT_P(int, refcount) |
|---|
| 293 | |
|---|
| 294 | DISPATCH(zend_bool, constants_updated) |
|---|
| 295 | |
|---|
| 296 | DISPATCH(zend_uint, ce_flags) |
|---|
| 297 | |
|---|
| 298 | |
|---|
| 299 | STRUCT(HashTable, default_properties, HashTable_zval_ptr) |
|---|
| 300 | IFCOPY(`dst->builtin_functions = src->builtin_functions;') |
|---|
| 301 | DONE(builtin_functions) |
|---|
| 302 | |
|---|
| 303 | STRUCT(HashTable, properties_info, HashTable_zend_property_info) |
|---|
| 304 | |
|---|
| 305 | STRUCT(HashTable, default_static_members, HashTable_zval_ptr) |
|---|
| 306 | IFCOPY(`dst->static_members = &dst->default_static_members;') |
|---|
| 307 | DONE(static_members) |
|---|
| 308 | |
|---|
| 309 | STRUCT_P(HashTable, static_members, HashTable_zval_ptr) |
|---|
| 310 | |
|---|
| 311 | STRUCT(HashTable, constants_table, HashTable_zval_ptr) |
|---|
| 312 | |
|---|
| 313 | |
|---|
| 314 | IFRESTORE(` |
|---|
| 315 | if (src->num_interfaces) { |
|---|
| 316 | CALLOC(dst->interfaces, zend_class_entry*, src->num_interfaces) |
|---|
| 317 | DONE(`interfaces') |
|---|
| 318 | } |
|---|
| 319 | else { |
|---|
| 320 | COPYNULL(interfaces) |
|---|
| 321 | } |
|---|
| 322 | ') |
|---|
| 323 | IFDASM(` |
|---|
| 324 | if (src->num_interfaces) { |
|---|
| 325 | /* |
|---|
| 326 | zval *arr; |
|---|
| 327 | ALLOC_INIT_ZVAL(arr); |
|---|
| 328 | array_init(arr); |
|---|
| 329 | for (i = 0; i < src->num_interfaces; i ++) { |
|---|
| 330 | zval *zv; |
|---|
| 331 | ALLOC_INIT_ZVAL(zv); |
|---|
| 332 | ZVAL_STRING(src->num_interfaces); |
|---|
| 333 | } |
|---|
| 334 | add_assoc_zval_ex(dst, ZEND_STRS("interfaces"), arr); |
|---|
| 335 | */ |
|---|
| 336 | DONE(`interfaces') |
|---|
| 337 | } |
|---|
| 338 | else { |
|---|
| 339 | COPYNULL(interfaces) |
|---|
| 340 | } |
|---|
| 341 | ') |
|---|
| 342 | IFRESTORE(`', ` |
|---|
| 343 | IFDASM(`', ` |
|---|
| 344 | DONE(`interfaces') |
|---|
| 345 | ') |
|---|
| 346 | ') |
|---|
| 347 | DISPATCH(zend_uint, num_interfaces) |
|---|
| 348 | |
|---|
| 349 | IFRESTORE(`COPY(filename)', `PROC_STRING(filename)') |
|---|
| 350 | DISPATCH(zend_uint, line_start) |
|---|
| 351 | DISPATCH(zend_uint, line_end) |
|---|
| 352 | |
|---|
| 353 | DISPATCH(zend_uint, doc_comment_len) |
|---|
| 354 | PROC_STRING_L(doc_comment, doc_comment_len) |
|---|
| 355 | |
|---|
| 356 | /* |
|---|
| 357 | COPY(serialize_func) |
|---|
| 358 | COPY(unserialize_func) |
|---|
| 359 | COPY(iterator_funcs) |
|---|
| 360 | COPY(create_object) |
|---|
| 361 | COPY(get_iterator) |
|---|
| 362 | COPY(interface_gets_implemented) |
|---|
| 363 | COPY(serialize) |
|---|
| 364 | COPY(unserialize) |
|---|
| 365 | /* deal with it inside xc_fix_method */ |
|---|
| 366 | SETNULL(constructor) |
|---|
| 367 | COPY(destructor) |
|---|
| 368 | COPY(clone) |
|---|
| 369 | COPY(__get) |
|---|
| 370 | COPY(__set) |
|---|
| 371 | /* should be >5.1 */ |
|---|
| 372 | |
|---|
| 373 | COPY(__unset) |
|---|
| 374 | COPY(__isset) |
|---|
| 375 | |
|---|
| 376 | COPY(__tostring) |
|---|
| 377 | |
|---|
| 378 | |
|---|
| 379 | COPY(__call) |
|---|
| 380 | /* |
|---|
| 381 | COPY(module) |
|---|
| 382 | |
|---|
| 383 | COPY(handle_function_call) |
|---|
| 384 | COPY(handle_property_get) |
|---|
| 385 | COPY(handle_property_set) |
|---|
| 386 | |
|---|
| 387 | |
|---|
| 388 | STRUCT(HashTable, function_table, HashTable_zend_function) |
|---|
| 389 | IFRESTORE(`dst->function_table.pDestructor = ZEND_FUNCTION_DTOR;') |
|---|
| 390 | IFCOPY(` |
|---|
| 391 | processor->active_class_entry_src = NULL; |
|---|
| 392 | processor->active_class_entry_dst = NULL; |
|---|
| 393 | ') |
|---|
| 394 | ') |
|---|
| 395 | |
|---|
| 396 | DEF_STRUCT_P_FUNC(`znode', , ` |
|---|
| 397 | DISPATCH(int, op_type) |
|---|
| 398 | |
|---|
| 399 | |
|---|
| 400 | |
|---|
| 401 | |
|---|
| 402 | /* compatible with zend optimizer */ |
|---|
| 403 | |
|---|
| 404 | |
|---|
| 405 | assert(src->op_type == IS_CONST || |
|---|
| 406 | src->op_type == IS_VAR || |
|---|
| 407 | src->op_type == XCACHE_IS_CV || |
|---|
| 408 | src->op_type == IS_TMP_VAR || |
|---|
| 409 | src->op_type == IS_UNUSED); |
|---|
| 410 | |
|---|
| 411 | |
|---|
| 412 | DISABLECHECK(` |
|---|
| 413 | switch (src->op_type) { |
|---|
| 414 | case IS_CONST: |
|---|
| 415 | STRUCT(zval, u.constant) |
|---|
| 416 | break; |
|---|
| 417 | IFCOPY(` |
|---|
| 418 | IFNOTMEMCPY(` |
|---|
| 419 | default: |
|---|
| 420 | memcpy(&dst->u, &src->u, sizeof(src->u)); |
|---|
| 421 | ') |
|---|
| 422 | ', ` |
|---|
| 423 | case IS_VAR: |
|---|
| 424 | case IS_TMP_VAR: |
|---|
| 425 | |
|---|
| 426 | case IS_CV: |
|---|
| 427 | |
|---|
| 428 | case 16: |
|---|
| 429 | |
|---|
| 430 | DISPATCH(zend_uint, u.var) |
|---|
| 431 | DISPATCH(zend_uint, u.EA.type) |
|---|
| 432 | break; |
|---|
| 433 | case IS_UNUSED: |
|---|
| 434 | IFDASM(`DISPATCH(zend_uint, u.var)') |
|---|
| 435 | DISPATCH(zend_uint, u.opline_num) |
|---|
| 436 | |
|---|
| 437 | DISPATCH(zend_uint, u.fetch_type) |
|---|
| 438 | |
|---|
| 439 | DISPATCH(zend_uint, u.EA.type) |
|---|
| 440 | break; |
|---|
| 441 | ') |
|---|
| 442 | } |
|---|
| 443 | ') |
|---|
| 444 | DONE(u) |
|---|
| 445 | ') |
|---|
| 446 | |
|---|
| 447 | DEF_STRUCT_P_FUNC(`zend_op', , ` |
|---|
| 448 | DISPATCH(zend_uchar, opcode) |
|---|
| 449 | STRUCT(znode, result) |
|---|
| 450 | STRUCT(znode, op1) |
|---|
| 451 | STRUCT(znode, op2) |
|---|
| 452 | DISPATCH(ulong, extended_value) |
|---|
| 453 | DISPATCH(uint, lineno) |
|---|
| 454 | |
|---|
| 455 | IFCOPY(` |
|---|
| 456 | switch (src->opcode) { |
|---|
| 457 | case ZEND_JMP: |
|---|
| 458 | dst->op1.u.jmp_addr = processor->active_opcodes_dst + (src->op1.u.jmp_addr - processor->active_opcodes_src); |
|---|
| 459 | break; |
|---|
| 460 | |
|---|
| 461 | case ZEND_JMPZ: |
|---|
| 462 | case ZEND_JMPNZ: |
|---|
| 463 | case ZEND_JMPZ_EX: |
|---|
| 464 | case ZEND_JMPNZ_EX: |
|---|
| 465 | dst->op2.u.jmp_addr = processor->active_opcodes_dst + (src->op2.u.jmp_addr - processor->active_opcodes_src); |
|---|
| 466 | break; |
|---|
| 467 | |
|---|
| 468 | default: |
|---|
| 469 | break; |
|---|
| 470 | } |
|---|
| 471 | ') |
|---|
| 472 | DISPATCH(opcode_handler_t, handler) |
|---|
| 473 | |
|---|
| 474 | ') |
|---|
| 475 | |
|---|
| 476 | DEF_STRUCT_P_FUNC(`zend_op_array', , ` |
|---|
| 477 | IFRESTORE(` |
|---|
| 478 | if (!processor->readonly_protection) { |
|---|
| 479 | /* really fast shallow copy */ |
|---|
| 480 | memcpy(dst, src, sizeof(src[0])); |
|---|
| 481 | dst->refcount[0] = 1000; |
|---|
| 482 | /* deep */ |
|---|
| 483 | STRUCT_P(HashTable, static_variables, HashTable_zval_ptr) |
|---|
| 484 | define(`SKIPASSERT_ONCE') |
|---|
| 485 | |
|---|
| 486 | IFRESTORE(` |
|---|
| 487 | |
|---|
| 488 | if (dst->scope) { |
|---|
| 489 | dst->scope = xc_get_class(processor, (zend_ulong) dst->scope); |
|---|
| 490 | xc_fix_method(processor, dst); |
|---|
| 491 | } |
|---|
| 492 | |
|---|
| 493 | ') |
|---|
| 494 | |
|---|
| 495 | } |
|---|
| 496 | else |
|---|
| 497 | ') |
|---|
| 498 | do { |
|---|
| 499 | |
|---|
| 500 | zend_uint ii; |
|---|
| 501 | int i; |
|---|
| 502 | |
|---|
| 503 | /* Common elements */ |
|---|
| 504 | DISPATCH(zend_uchar, type) |
|---|
| 505 | PROC_ZSTRING(, function_name) |
|---|
| 506 | |
|---|
| 507 | IFRESTORE(` |
|---|
| 508 | if (dst->scope) { |
|---|
| 509 | dst->scope = xc_get_class(processor, (zend_ulong) dst->scope); |
|---|
| 510 | xc_fix_method(processor, dst); |
|---|
| 511 | } |
|---|
| 512 | DONE(scope) |
|---|
| 513 | ', ` |
|---|
| 514 | PROC_CLASS_ENTRY_P(scope) |
|---|
| 515 | ') |
|---|
| 516 | DISPATCH(zend_uint, fn_flags) |
|---|
| 517 | |
|---|
| 518 | IFSTORE(`dst->prototype = (processor->active_class_entry_src && src->prototype) ? (zend_function *) -1 : NULL; DONE(prototype)', ` |
|---|
| 519 | IFRESTORE(`do { |
|---|
| 520 | zend_function *parent; |
|---|
| 521 | if (src->prototype != NULL |
|---|
| 522 | && zend_u_hash_find(&(processor->active_class_entry_dst->parent->function_table), |
|---|
| 523 | UG(unicode) ? IS_UNICODE : IS_STRING, |
|---|
| 524 | src->function_name, xc_zstrlen(UG(unicode), src->function_name) + 1, |
|---|
| 525 | (void **) &parent) == SUCCESS) { |
|---|
| 526 | /* see do_inherit_method_check() */ |
|---|
| 527 | if ((parent->common.fn_flags & ZEND_ACC_ABSTRACT)) { |
|---|
| 528 | dst->prototype = parent; |
|---|
| 529 | } |
|---|
| 530 | else { |
|---|
| 531 | dst->prototype = parent->common.prototype; |
|---|
| 532 | } |
|---|
| 533 | } |
|---|
| 534 | else { |
|---|
| 535 | dst->prototype = NULL; |
|---|
| 536 | } |
|---|
| 537 | DONE(prototype) |
|---|
| 538 | } while (0); |
|---|
| 539 | ', ` |
|---|
| 540 | COPYNULL(prototype) |
|---|
| 541 | ') |
|---|
| 542 | ') |
|---|
| 543 | STRUCT_ARRAY_I(num_args, zend_arg_info, arg_info) |
|---|
| 544 | DISPATCH(zend_uint, num_args) |
|---|
| 545 | DISPATCH(zend_uint, required_num_args) |
|---|
| 546 | DISPATCH(zend_bool, pass_rest_by_reference) |
|---|
| 547 | |
|---|
| 548 | if (src->arg_types) { |
|---|
| 549 | ALLOC(dst->arg_types, zend_uchar, src->arg_types[0] + 1) |
|---|
| 550 | IFCOPY(`memcpy(dst->arg_types, src->arg_types, sizeof(src->arg_types[0]) * (src->arg_types[0]+1));') |
|---|
| 551 | IFDASM(`do { |
|---|
| 552 | zend_uint ii; |
|---|
| 553 | int i; |
|---|
| 554 | zval *zv; |
|---|
| 555 | ALLOC_INIT_ZVAL(zv); |
|---|
| 556 | array_init(zv); |
|---|
| 557 | for (i = 0; i < src->arg_types[0]; i ++) { |
|---|
| 558 | add_next_index_long(zv, src->arg_types[i + 1]); |
|---|
| 559 | } |
|---|
| 560 | add_assoc_zval_ex(dst, ZEND_STRS("arg_types"), zv); |
|---|
| 561 | } while (0);') |
|---|
| 562 | DONE(arg_types) |
|---|
| 563 | } |
|---|
| 564 | else { |
|---|
| 565 | IFDASM(`do { |
|---|
| 566 | /* empty array */ |
|---|
| 567 | zval *zv; |
|---|
| 568 | ALLOC_INIT_ZVAL(zv); |
|---|
| 569 | array_init(zv); |
|---|
| 570 | add_assoc_zval_ex(dst, ZEND_STRS("arg_types"), zv); |
|---|
| 571 | } while (0); |
|---|
| 572 | DONE(arg_types) |
|---|
| 573 | ', ` |
|---|
| 574 | COPYNULL(arg_types) |
|---|
| 575 | ') |
|---|
| 576 | } |
|---|
| 577 | |
|---|
| 578 | DISPATCH(unsigned char, return_reference) |
|---|
| 579 | /* END of common elements */ |
|---|
| 580 | |
|---|
| 581 | |
|---|
| 582 | |
|---|
| 583 | |
|---|
| 584 | STRUCT_P(zend_uint, refcount) |
|---|
| 585 | UNFIXPOINTER(zend_uint, refcount) |
|---|
| 586 | |
|---|
| 587 | pushdef(`AFTER_ALLOC', `IFCOPY(` |
|---|
| 588 | processor->active_opcodes_dst = dst->opcodes; |
|---|
| 589 | processor->active_opcodes_src = src->opcodes; |
|---|
| 590 | ')') |
|---|
| 591 | STRUCT_ARRAY_I(last, zend_op, opcodes) |
|---|
| 592 | popdef(`AFTER_ALLOC') |
|---|
| 593 | DISPATCH(zend_uint, last) |
|---|
| 594 | IFCOPY(`dst->size = src->last;DONE(size)', `DISPATCH(zend_uint, size)') |
|---|
| 595 | |
|---|
| 596 | |
|---|
| 597 | STRUCT_ARRAY(last_var, zend_compiled_variable, vars) |
|---|
| 598 | DISPATCH(int, last_var) |
|---|
| 599 | IFCOPY(`dst->size_var = src->last_var;DONE(size_var)', `DISPATCH(zend_uint, size_var)') |
|---|
| 600 | |
|---|
| 601 | |
|---|
| 602 | IFDASM(` |
|---|
| 603 | sinclude(srcdir`/processor/zend_cv.m4') |
|---|
| 604 | ') |
|---|
| 605 | |
|---|
| 606 | |
|---|
| 607 | DISPATCH(zend_uint, T) |
|---|
| 608 | |
|---|
| 609 | STRUCT_ARRAY_I(last_brk_cont, zend_brk_cont_element, brk_cont_array) |
|---|
| 610 | DISPATCH(zend_uint, last_brk_cont) |
|---|
| 611 | DISPATCH(zend_uint, current_brk_cont) |
|---|
| 612 | |
|---|
| 613 | DISPATCH(zend_bool, uses_globals) |
|---|
| 614 | |
|---|
| 615 | |
|---|
| 616 | |
|---|
| 617 | STRUCT_ARRAY(last_try_catch, zend_try_catch_element, try_catch_array) |
|---|
| 618 | DISPATCH(int, last_try_catch) |
|---|
| 619 | |
|---|
| 620 | |
|---|
| 621 | STRUCT_P(HashTable, static_variables, HashTable_zval_ptr) |
|---|
| 622 | |
|---|
| 623 | COPY(start_op) |
|---|
| 624 | DISPATCH(int, backpatch_count) |
|---|
| 625 | |
|---|
| 626 | DISPATCH(zend_bool, done_pass_two) |
|---|
| 627 | |
|---|
| 628 | DISPATCH(zend_bool, uses_this) |
|---|
| 629 | |
|---|
| 630 | |
|---|
| 631 | IFRESTORE(`COPY(filename)', `PROC_STRING(filename)') |
|---|
| 632 | |
|---|
| 633 | PROC_STRING(script_encoding) |
|---|
| 634 | |
|---|
| 635 | |
|---|
| 636 | DISPATCH(zend_uint, line_start) |
|---|
| 637 | DISPATCH(zend_uint, line_end) |
|---|
| 638 | DISPATCH(int, doc_comment_len) |
|---|
| 639 | PROC_STRING_L(doc_comment, doc_comment_len) |
|---|
| 640 | |
|---|
| 641 | |
|---|
| 642 | /* reserved */ |
|---|
| 643 | DONE(reserved) |
|---|
| 644 | |
|---|
| 645 | DISPATCH(zend_bool, created_by_eval) |
|---|
| 646 | |
|---|
| 647 | } while (0); |
|---|
| 648 | ') |
|---|
| 649 | |
|---|
| 650 | |
|---|
| 651 | |
|---|
| 652 | DEF_STRUCT_P_FUNC(`xc_constinfo_t', , ` |
|---|
| 653 | DISPATCH(zend_uint, key_size) |
|---|
| 654 | |
|---|
| 655 | DISPATCH(zend_uchar, type) |
|---|
| 656 | |
|---|
| 657 | IFRESTORE(`COPY(key)', ` |
|---|
| 658 | PROC_ZSTRING_N(type, key, key_size) |
|---|
| 659 | ') |
|---|
| 660 | STRUCT(zend_constant, constant) |
|---|
| 661 | ') |
|---|
| 662 | |
|---|
| 663 | |
|---|
| 664 | DEF_STRUCT_P_FUNC(`xc_funcinfo_t', , ` |
|---|
| 665 | DISPATCH(zend_uint, key_size) |
|---|
| 666 | |
|---|
| 667 | DISPATCH(zend_uchar, type) |
|---|
| 668 | |
|---|
| 669 | IFRESTORE(`COPY(key)', ` |
|---|
| 670 | PROC_ZSTRING_N(type, key, key_size) |
|---|
| 671 | ') |
|---|
| 672 | STRUCT(zend_function, func) |
|---|
| 673 | ') |
|---|
| 674 | |
|---|
| 675 | DEF_STRUCT_P_FUNC(`xc_classinfo_t', , ` |
|---|
| 676 | DISPATCH(zend_uint, key_size) |
|---|
| 677 | |
|---|
| 678 | DISPATCH(zend_uchar, type) |
|---|
| 679 | |
|---|
| 680 | IFRESTORE(`COPY(key)', ` |
|---|
| 681 | PROC_ZSTRING_N(type, key, key_size) |
|---|
| 682 | ') |
|---|
| 683 | |
|---|
| 684 | STRUCT_P(zend_class_entry, cest) |
|---|
| 685 | |
|---|
| 686 | STRUCT(zend_class_entry, cest) |
|---|
| 687 | |
|---|
| 688 | ') |
|---|
| 689 | |
|---|
| 690 | DEF_STRUCT_P_FUNC(`xc_entry_data_php_t', , ` |
|---|
| 691 | zend_uint i; |
|---|
| 692 | |
|---|
| 693 | |
|---|
| 694 | DISPATCH(int, device) |
|---|
| 695 | DISPATCH(int, inode) |
|---|
| 696 | |
|---|
| 697 | DISPATCH(size_t, sourcesize) |
|---|
| 698 | |
|---|
| 699 | DISPATCH(time_t, mtime) |
|---|
| 700 | |
|---|
| 701 | STRUCT_P(zend_op_array, op_array) |
|---|
| 702 | |
|---|
| 703 | |
|---|
| 704 | DISPATCH(zend_uint, constinfo_cnt) |
|---|
| 705 | STRUCT_ARRAY(constinfo_cnt, xc_constinfo_t, constinfos) |
|---|
| 706 | |
|---|
| 707 | |
|---|
| 708 | DISPATCH(zend_uint, funcinfo_cnt) |
|---|
| 709 | STRUCT_ARRAY(funcinfo_cnt, xc_funcinfo_t, funcinfos) |
|---|
| 710 | |
|---|
| 711 | DISPATCH(zend_uint, classinfo_cnt) |
|---|
| 712 | pushdef(`BEFORE_LOOP', ` |
|---|
| 713 | IFCOPY(` |
|---|
| 714 | processor->active_class_num = i + 1; |
|---|
| 715 | ') |
|---|
| 716 | ') |
|---|
| 717 | STRUCT_ARRAY(classinfo_cnt, xc_classinfo_t, classinfos) |
|---|
| 718 | popdef(`BEFORE_LOOP') |
|---|
| 719 | ') |
|---|
| 720 | |
|---|
| 721 | DEF_STRUCT_P_FUNC(`xc_entry_data_var_t', , ` |
|---|
| 722 | STRUCT_P_EX(zval_ptr, dst->value, src->value, `value', `', `&') |
|---|
| 723 | DONE(value) |
|---|
| 724 | ') |
|---|
| 725 | |
|---|
| 726 | |
|---|
| 727 | DEF_STRUCT_P_FUNC(`xc_entry_t', , ` |
|---|
| 728 | IFCOPY(` |
|---|
| 729 | processor->xce_dst = dst; |
|---|
| 730 | processor->xce_src = src; |
|---|
| 731 | ') |
|---|
| 732 | DISPATCH(xc_entry_type_t, type) |
|---|
| 733 | DISPATCH(size_t, size) |
|---|
| 734 | |
|---|
| 735 | DISPATCH(xc_hash_value_t, hvalue) |
|---|
| 736 | COPY(cache) |
|---|
| 737 | /* skip */ |
|---|
| 738 | DONE(next) |
|---|
| 739 | |
|---|
| 740 | IFSTORE(`dst->refcount = 0; DONE(refcount)', `DISPATCH(long, refcount)') |
|---|
| 741 | |
|---|
| 742 | DISPATCH(time_t, ctime) |
|---|
| 743 | DISPATCH(time_t, atime) |
|---|
| 744 | DISPATCH(time_t, dtime) |
|---|
| 745 | DISPATCH(long, ttl) |
|---|
| 746 | DISPATCH(zend_ulong, hits) |
|---|
| 747 | |
|---|
| 748 | DISPATCH(zend_uchar, name_type) |
|---|
| 749 | |
|---|
| 750 | |
|---|
| 751 | DISABLECHECK(` |
|---|
| 752 | |
|---|
| 753 | if (src->name_type == IS_UNICODE) { |
|---|
| 754 | DISPATCH(int32_t, name.ustr.len) |
|---|
| 755 | } |
|---|
| 756 | else { |
|---|
| 757 | DISPATCH(int, name.str.len) |
|---|
| 758 | } |
|---|
| 759 | |
|---|
| 760 | DISPATCH(int, name.str.len) |
|---|
| 761 | |
|---|
| 762 | IFRESTORE(`COPY(name.str.val)', ` |
|---|
| 763 | |
|---|
| 764 | PROC_ZSTRING_L(name_type, name.uni.val, name.uni.len) |
|---|
| 765 | |
|---|
| 766 | PROC_STRING_L(name.str.val, name.str.len) |
|---|
| 767 | |
|---|
| 768 | ') |
|---|
| 769 | ') |
|---|
| 770 | DONE(name) |
|---|
| 771 | |
|---|
| 772 | |
|---|
| 773 | |
|---|
| 774 | DISABLECHECK(` |
|---|
| 775 | switch (src->type) { |
|---|
| 776 | case XC_TYPE_PHP: |
|---|
| 777 | STRUCT_P(xc_entry_data_php_t, data.php) |
|---|
| 778 | break; |
|---|
| 779 | case XC_TYPE_VAR: |
|---|
| 780 | STRUCT_P(xc_entry_data_var_t, data.var) |
|---|
| 781 | break; |
|---|
| 782 | default: |
|---|
| 783 | assert(0); |
|---|
| 784 | } |
|---|
| 785 | ') |
|---|
| 786 | DONE(data) |
|---|
| 787 | |
|---|
| 788 | ') |
|---|
| 789 | |
|---|
| 790 | |
|---|