root/Zend/zend_compile.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2    +----------------------------------------------------------------------+
   3    | Zend Engine                                                          |
   4    +----------------------------------------------------------------------+
   5    | Copyright (c) 1998-2016 Zend Technologies Ltd. (http://www.zend.com) |
   6    +----------------------------------------------------------------------+
   7    | This source file is subject to version 2.00 of the Zend license,     |
   8    | that is bundled with this package in the file LICENSE, and is        |
   9    | available through the world-wide-web at the following url:           |
  10    | http://www.zend.com/license/2_00.txt.                                |
  11    | If you did not receive a copy of the Zend license and are unable to  |
  12    | obtain it through the world-wide-web, please send a note to          |
  13    | license@zend.com so we can mail you a copy immediately.              |
  14    +----------------------------------------------------------------------+
  15    | Authors: Andi Gutmans <andi@zend.com>                                |
  16    |          Zeev Suraski <zeev@zend.com>                                |
  17    +----------------------------------------------------------------------+
  18 */
  19 
  20 /* $Id$ */
  21 
  22 #ifndef ZEND_COMPILE_H
  23 #define ZEND_COMPILE_H
  24 
  25 #include "zend.h"
  26 #include "zend_ast.h"
  27 
  28 #ifdef HAVE_STDARG_H
  29 # include <stdarg.h>
  30 #endif
  31 
  32 #include "zend_llist.h"
  33 
  34 #define DEBUG_ZEND 0
  35 
  36 #define FREE_PNODE(znode)       zval_dtor(&znode->u.constant);
  37 
  38 #define SET_UNUSED(op)  op ## _type = IS_UNUSED
  39 
  40 #define INC_BPC(op_array)       if (op_array->fn_flags & ZEND_ACC_INTERACTIVE) { (CG(context).backpatch_count++); }
  41 #define DEC_BPC(op_array)       if (op_array->fn_flags & ZEND_ACC_INTERACTIVE) { (CG(context).backpatch_count--); }
  42 #define HANDLE_INTERACTIVE()  if (CG(active_op_array)->fn_flags & ZEND_ACC_INTERACTIVE) { execute_new_code(TSRMLS_C); }
  43 #define DO_TICKS()            if (Z_LVAL(CG(declarables).ticks)) { zend_do_ticks(TSRMLS_C); }
  44 
  45 #define RESET_DOC_COMMENT()        \
  46     {                              \
  47         if (CG(doc_comment)) {     \
  48           efree(CG(doc_comment));  \
  49           CG(doc_comment) = NULL;  \
  50         }                          \
  51         CG(doc_comment_len) = 0;   \
  52     }
  53 
  54 typedef struct _zend_op_array zend_op_array;
  55 typedef struct _zend_op zend_op;
  56 
  57 typedef struct _zend_compiler_context {
  58         zend_uint  opcodes_size;
  59         int        vars_size;
  60         int        literals_size;
  61         int        current_brk_cont;
  62         int        backpatch_count;
  63         int        nested_calls;
  64         int        used_stack;
  65         int        in_finally;
  66         HashTable *labels;
  67 } zend_compiler_context;
  68 
  69 typedef struct _zend_literal {
  70         zval       constant;
  71         zend_ulong hash_value;
  72         zend_uint  cache_slot;
  73 } zend_literal;
  74 
  75 #define Z_HASH_P(zv) \
  76         (((zend_literal*)(zv))->hash_value)
  77 
  78 typedef union _znode_op {
  79         zend_uint      constant;
  80         zend_uint      var;
  81         zend_uint      num;
  82         zend_ulong     hash;
  83         zend_uint      opline_num; /*  Needs to be signed */
  84         zend_op       *jmp_addr;
  85         zval          *zv;
  86         zend_literal  *literal;
  87         void          *ptr;        /* Used for passing pointers from the compile to execution phase, currently used for traits */
  88 } znode_op;
  89 
  90 typedef struct _znode { /* used only during compilation */
  91         int op_type;
  92         union {
  93                 znode_op op;
  94                 zval constant; /* replaced by literal/zv */
  95                 zend_op_array *op_array;
  96                 zend_ast *ast;
  97         } u;
  98         zend_uint EA;      /* extended attributes */
  99 } znode;
 100 
 101 typedef struct _zend_execute_data zend_execute_data;
 102 
 103 #define ZEND_OPCODE_HANDLER_ARGS zend_execute_data *execute_data TSRMLS_DC
 104 #define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU execute_data TSRMLS_CC
 105 
 106 typedef int (*user_opcode_handler_t) (ZEND_OPCODE_HANDLER_ARGS);
 107 typedef int (ZEND_FASTCALL *opcode_handler_t) (ZEND_OPCODE_HANDLER_ARGS);
 108 
 109 extern ZEND_API opcode_handler_t *zend_opcode_handlers;
 110 
 111 struct _zend_op {
 112         opcode_handler_t handler;
 113         znode_op op1;
 114         znode_op op2;
 115         znode_op result;
 116         ulong extended_value;
 117         uint lineno;
 118         zend_uchar opcode;
 119         zend_uchar op1_type;
 120         zend_uchar op2_type;
 121         zend_uchar result_type;
 122 };
 123 
 124 
 125 typedef struct _zend_brk_cont_element {
 126         int start;
 127         int cont;
 128         int brk;
 129         int parent;
 130 } zend_brk_cont_element;
 131 
 132 typedef struct _zend_label {
 133         int brk_cont;
 134         zend_uint opline_num;
 135 } zend_label;
 136 
 137 typedef struct _zend_try_catch_element {
 138         zend_uint try_op;
 139         zend_uint catch_op;  /* ketchup! */
 140         zend_uint finally_op;
 141         zend_uint finally_end;
 142 } zend_try_catch_element;
 143 
 144 #if SIZEOF_LONG == 8
 145 #define THIS_HASHVAL 210728972157UL
 146 #else
 147 #define THIS_HASHVAL 275574653UL
 148 #endif
 149 
 150 /* method flags (types) */
 151 #define ZEND_ACC_STATIC                 0x01
 152 #define ZEND_ACC_ABSTRACT               0x02
 153 #define ZEND_ACC_FINAL                  0x04
 154 #define ZEND_ACC_IMPLEMENTED_ABSTRACT           0x08
 155 
 156 /* class flags (types) */
 157 /* ZEND_ACC_IMPLICIT_ABSTRACT_CLASS is used for abstract classes (since it is set by any abstract method even interfaces MAY have it set, too). */
 158 /* ZEND_ACC_EXPLICIT_ABSTRACT_CLASS denotes that a class was explicitly defined as abstract by using the keyword. */
 159 #define ZEND_ACC_IMPLICIT_ABSTRACT_CLASS        0x10
 160 #define ZEND_ACC_EXPLICIT_ABSTRACT_CLASS        0x20
 161 #define ZEND_ACC_FINAL_CLASS                0x40
 162 #define ZEND_ACC_INTERFACE                          0x80
 163 #define ZEND_ACC_TRAIT                                          0x120
 164 
 165 /* op_array flags */
 166 #define ZEND_ACC_INTERACTIVE                            0x10
 167 
 168 /* method flags (visibility) */
 169 /* The order of those must be kept - public < protected < private */
 170 #define ZEND_ACC_PUBLIC         0x100
 171 #define ZEND_ACC_PROTECTED      0x200
 172 #define ZEND_ACC_PRIVATE        0x400
 173 #define ZEND_ACC_PPP_MASK  (ZEND_ACC_PUBLIC | ZEND_ACC_PROTECTED | ZEND_ACC_PRIVATE)
 174 
 175 #define ZEND_ACC_CHANGED        0x800
 176 #define ZEND_ACC_IMPLICIT_PUBLIC        0x1000
 177 
 178 /* method flags (special method detection) */
 179 #define ZEND_ACC_CTOR           0x2000
 180 #define ZEND_ACC_DTOR           0x4000
 181 #define ZEND_ACC_CLONE          0x8000
 182 
 183 /* method flag (bc only), any method that has this flag can be used statically and non statically. */
 184 #define ZEND_ACC_ALLOW_STATIC   0x10000
 185 
 186 /* shadow of parent's private method/property */
 187 #define ZEND_ACC_SHADOW 0x20000
 188 
 189 /* deprecation flag */
 190 #define ZEND_ACC_DEPRECATED 0x40000
 191 
 192 /* class implement interface(s) flag */
 193 #define ZEND_ACC_IMPLEMENT_INTERFACES 0x80000
 194 #define ZEND_ACC_IMPLEMENT_TRAITS         0x400000
 195 
 196 /* class constants updated */
 197 #define ZEND_ACC_CONSTANTS_UPDATED        0x100000
 198 
 199 /* user class has methods with static variables */
 200 #define ZEND_HAS_STATIC_IN_METHODS    0x800000
 201 
 202 
 203 #define ZEND_ACC_CLOSURE              0x100000
 204 #define ZEND_ACC_GENERATOR            0x800000
 205 
 206 /* function flag for internal user call handlers __call, __callstatic */
 207 #define ZEND_ACC_CALL_VIA_HANDLER     0x200000
 208 
 209 /* disable inline caching */
 210 #define ZEND_ACC_NEVER_CACHE          0x400000
 211 
 212 #define ZEND_ACC_VARIADIC                               0x1000000
 213 
 214 #define ZEND_ACC_RETURN_REFERENCE               0x4000000
 215 #define ZEND_ACC_DONE_PASS_TWO                  0x8000000
 216 
 217 /* function has arguments with type hinting */
 218 #define ZEND_ACC_HAS_TYPE_HINTS                 0x10000000
 219 
 220 char *zend_visibility_string(zend_uint fn_flags);
 221 
 222 
 223 typedef struct _zend_property_info {
 224         zend_uint flags;
 225         const char *name;
 226         int name_length;
 227         ulong h;
 228         int offset;
 229         const char *doc_comment;
 230         int doc_comment_len;
 231         zend_class_entry *ce;
 232 } zend_property_info;
 233 
 234 
 235 typedef struct _zend_arg_info {
 236         const char *name;
 237         zend_uint name_len;
 238         const char *class_name;
 239         zend_uint class_name_len;
 240         zend_uchar type_hint;
 241         zend_uchar pass_by_reference;
 242         zend_bool allow_null;
 243         zend_bool is_variadic;
 244 } zend_arg_info;
 245 
 246 /* the following structure repeats the layout of zend_arg_info,
 247  * but its fields have different meaning. It's used as the first element of
 248  * arg_info array to define properties of internal functions.
 249  */
 250 typedef struct _zend_internal_function_info {
 251         const char *_name;
 252         zend_uint _name_len;
 253         const char *_class_name;
 254         zend_uint required_num_args;
 255         zend_uchar _type_hint;
 256         zend_bool return_reference;
 257         zend_bool _allow_null;
 258         zend_bool _is_variadic;
 259 } zend_internal_function_info;
 260 
 261 typedef struct _zend_compiled_variable {
 262         const char *name;
 263         int name_len;
 264         ulong hash_value;
 265 } zend_compiled_variable;
 266 
 267 struct _zend_op_array {
 268         /* Common elements */
 269         zend_uchar type;
 270         const char *function_name;
 271         zend_class_entry *scope;
 272         zend_uint fn_flags;
 273         union _zend_function *prototype;
 274         zend_uint num_args;
 275         zend_uint required_num_args;
 276         zend_arg_info *arg_info;
 277         /* END of common elements */
 278 
 279         zend_uint *refcount;
 280 
 281         zend_op *opcodes;
 282         zend_uint last;
 283 
 284         zend_compiled_variable *vars;
 285         int last_var;
 286 
 287         zend_uint T;
 288 
 289         zend_uint nested_calls;
 290         zend_uint used_stack;
 291 
 292         zend_brk_cont_element *brk_cont_array;
 293         int last_brk_cont;
 294 
 295         zend_try_catch_element *try_catch_array;
 296         int last_try_catch;
 297         zend_bool has_finally_block;
 298 
 299         /* static variables support */
 300         HashTable *static_variables;
 301 
 302         zend_uint this_var;
 303 
 304         const char *filename;
 305         zend_uint line_start;
 306         zend_uint line_end;
 307         const char *doc_comment;
 308         zend_uint doc_comment_len;
 309         zend_uint early_binding; /* the linked list of delayed declarations */
 310 
 311         zend_literal *literals;
 312         int last_literal;
 313 
 314         void **run_time_cache;
 315         int  last_cache_slot;
 316 
 317         void *reserved[ZEND_MAX_RESERVED_RESOURCES];
 318 };
 319 
 320 
 321 #define ZEND_RETURN_VALUE                               0
 322 #define ZEND_RETURN_REFERENCE                   1
 323 
 324 typedef struct _zend_internal_function {
 325         /* Common elements */
 326         zend_uchar type;
 327         const char * function_name;
 328         zend_class_entry *scope;
 329         zend_uint fn_flags;
 330         union _zend_function *prototype;
 331         zend_uint num_args;
 332         zend_uint required_num_args;
 333         zend_arg_info *arg_info;
 334         /* END of common elements */
 335 
 336         void (*handler)(INTERNAL_FUNCTION_PARAMETERS);
 337         struct _zend_module_entry *module;
 338 } zend_internal_function;
 339 
 340 #define ZEND_FN_SCOPE_NAME(function)  ((function) && (function)->common.scope ? (function)->common.scope->name : "")
 341 
 342 typedef union _zend_function {
 343         zend_uchar type;        /* MUST be the first element of this struct! */
 344 
 345         struct {
 346                 zend_uchar type;  /* never used */
 347                 const char *function_name;
 348                 zend_class_entry *scope;
 349                 zend_uint fn_flags;
 350                 union _zend_function *prototype;
 351                 zend_uint num_args;
 352                 zend_uint required_num_args;
 353                 zend_arg_info *arg_info;
 354         } common;
 355 
 356         zend_op_array op_array;
 357         zend_internal_function internal_function;
 358 } zend_function;
 359 
 360 
 361 typedef struct _zend_function_state {
 362         zend_function *function;
 363         void **arguments;
 364 } zend_function_state;
 365 
 366 typedef struct _zend_function_call_entry {
 367         zend_function *fbc;
 368         zend_uint arg_num;
 369         zend_bool uses_argument_unpacking;
 370 } zend_function_call_entry;
 371 
 372 typedef struct _zend_switch_entry {
 373         znode cond;
 374         int default_case;
 375         int control_var;
 376 } zend_switch_entry;
 377 
 378 
 379 typedef struct _list_llist_element {
 380         znode var;
 381         zend_llist dimensions;
 382         znode value;
 383 } list_llist_element;
 384 
 385 union _temp_variable;
 386 
 387 typedef struct _call_slot {
 388         zend_function     *fbc;
 389         zval              *object;
 390         zend_class_entry  *called_scope;
 391         zend_uint          num_additional_args;
 392         zend_bool          is_ctor_call;
 393         zend_bool          is_ctor_result_used;
 394 } call_slot;
 395 
 396 struct _zend_execute_data {
 397         struct _zend_op *opline;
 398         zend_function_state function_state;
 399         zend_op_array *op_array;
 400         zval *object;
 401         HashTable *symbol_table;
 402         struct _zend_execute_data *prev_execute_data;
 403         zval *old_error_reporting;
 404         zend_bool nested;
 405         zval **original_return_value;
 406         zend_class_entry *current_scope;
 407         zend_class_entry *current_called_scope;
 408         zval *current_this;
 409         struct _zend_op *fast_ret; /* used by FAST_CALL/FAST_RET (finally keyword) */
 410         zval *delayed_exception;
 411         call_slot *call_slots;
 412         call_slot *call;
 413 };
 414 
 415 #define EX(element) execute_data.element
 416 
 417 #define EX_TMP_VAR(ex, n)          ((temp_variable*)(((char*)(ex)) + ((int)(n))))
 418 #define EX_TMP_VAR_NUM(ex, n)  (EX_TMP_VAR(ex, 0) - (1 + (n)))
 419 
 420 #define EX_CV_NUM(ex, n)       (((zval***)(((char*)(ex))+ZEND_MM_ALIGNED_SIZE(sizeof(zend_execute_data))))+(n))
 421 
 422 
 423 #define IS_CONST        (1<<0)
 424 #define IS_TMP_VAR      (1<<1)
 425 #define IS_VAR          (1<<2)
 426 #define IS_UNUSED       (1<<3)  /* Unused variable */
 427 #define IS_CV           (1<<4)  /* Compiled variable */
 428 
 429 #define EXT_TYPE_UNUSED (1<<5)
 430 
 431 #include "zend_globals.h"
 432 
 433 BEGIN_EXTERN_C()
 434 
 435 void init_compiler(TSRMLS_D);
 436 void shutdown_compiler(TSRMLS_D);
 437 void zend_init_compiler_data_structures(TSRMLS_D);
 438 void zend_init_compiler_context(TSRMLS_D);
 439 
 440 extern ZEND_API zend_op_array *(*zend_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC);
 441 extern ZEND_API zend_op_array *(*zend_compile_string)(zval *source_string, char *filename TSRMLS_DC);
 442 
 443 ZEND_API int lex_scan(zval *zendlval TSRMLS_DC);
 444 void startup_scanner(TSRMLS_D);
 445 void shutdown_scanner(TSRMLS_D);
 446 
 447 ZEND_API char *zend_set_compiled_filename(const char *new_compiled_filename TSRMLS_DC);
 448 ZEND_API void zend_restore_compiled_filename(char *original_compiled_filename TSRMLS_DC);
 449 ZEND_API char *zend_get_compiled_filename(TSRMLS_D);
 450 ZEND_API int zend_get_compiled_lineno(TSRMLS_D);
 451 ZEND_API size_t zend_get_scanned_file_offset(TSRMLS_D);
 452 
 453 void zend_resolve_non_class_name(znode *element_name, zend_bool *check_namespace, zend_bool case_sensitive, HashTable *current_import_sub TSRMLS_DC);
 454 void zend_resolve_function_name(znode *element_name, zend_bool *check_namespace TSRMLS_DC);
 455 void zend_resolve_const_name(znode *element_name, zend_bool *check_namespace TSRMLS_DC);
 456 void zend_resolve_class_name(znode *class_name TSRMLS_DC);
 457 ZEND_API const char* zend_get_compiled_variable_name(const zend_op_array *op_array, zend_uint var, int* name_len);
 458 
 459 #ifdef ZTS
 460 const char *zend_get_zendtext(TSRMLS_D);
 461 int zend_get_zendleng(TSRMLS_D);
 462 #endif
 463 
 464 
 465 /* parser-driven code generators */
 466 void zend_do_binary_op(zend_uchar op, znode *result, const znode *op1, const znode *op2 TSRMLS_DC);
 467 void zend_do_unary_op(zend_uchar op, znode *result, const znode *op1 TSRMLS_DC);
 468 void zend_do_binary_assign_op(zend_uchar op, znode *result, const znode *op1, const znode *op2 TSRMLS_DC);
 469 void zend_do_assign(znode *result, znode *variable, znode *value TSRMLS_DC);
 470 void zend_do_assign_ref(znode *result, const znode *lvar, const znode *rvar TSRMLS_DC);
 471 void fetch_simple_variable(znode *result, znode *varname, int bp TSRMLS_DC);
 472 void fetch_simple_variable_ex(znode *result, znode *varname, int bp, zend_uchar op TSRMLS_DC);
 473 void zend_do_indirect_references(znode *result, const znode *num_references, znode *variable TSRMLS_DC);
 474 void zend_do_fetch_static_variable(znode *varname, const znode *static_assignment, int fetch_type TSRMLS_DC);
 475 void zend_do_fetch_global_variable(znode *varname, const znode *static_assignment, int fetch_type TSRMLS_DC);
 476 
 477 void fetch_array_begin(znode *result, znode *varname, znode *first_dim TSRMLS_DC);
 478 void fetch_array_dim(znode *result, const znode *parent, const znode *dim TSRMLS_DC);
 479 void fetch_string_offset(znode *result, const znode *parent, const znode *offset TSRMLS_DC);
 480 void zend_do_fetch_static_member(znode *result, znode *class_znode TSRMLS_DC);
 481 void zend_do_print(znode *result, const znode *arg TSRMLS_DC);
 482 void zend_do_echo(const znode *arg TSRMLS_DC);
 483 typedef int (*unary_op_type)(zval *, zval * TSRMLS_DC);
 484 typedef int (*binary_op_type)(zval *, zval *, zval * TSRMLS_DC);
 485 ZEND_API unary_op_type get_unary_op(int opcode);
 486 ZEND_API binary_op_type get_binary_op(int opcode);
 487 
 488 void zend_do_while_cond(const znode *expr, znode *close_bracket_token TSRMLS_DC);
 489 void zend_do_while_end(const znode *while_token, const znode *close_bracket_token TSRMLS_DC);
 490 void zend_do_do_while_begin(TSRMLS_D);
 491 void zend_do_do_while_end(const znode *do_token, const znode *expr_open_bracket, const znode *expr TSRMLS_DC);
 492 
 493 
 494 void zend_do_if_cond(const znode *cond, znode *closing_bracket_token TSRMLS_DC);
 495 void zend_do_if_after_statement(const znode *closing_bracket_token, unsigned char initialize TSRMLS_DC);
 496 void zend_do_if_end(TSRMLS_D);
 497 
 498 void zend_do_for_cond(const znode *expr, znode *second_semicolon_token TSRMLS_DC);
 499 void zend_do_for_before_statement(const znode *cond_start, const znode *second_semicolon_token TSRMLS_DC);
 500 void zend_do_for_end(const znode *second_semicolon_token TSRMLS_DC);
 501 
 502 void zend_do_pre_incdec(znode *result, const znode *op1, zend_uchar op TSRMLS_DC);
 503 void zend_do_post_incdec(znode *result, const znode *op1, zend_uchar op TSRMLS_DC);
 504 
 505 void zend_do_begin_variable_parse(TSRMLS_D);
 506 void zend_do_end_variable_parse(znode *variable, int type, int arg_offset TSRMLS_DC);
 507 
 508 void zend_check_writable_variable(const znode *variable);
 509 
 510 void zend_do_free(znode *op1 TSRMLS_DC);
 511 
 512 void zend_do_add_string(znode *result, const znode *op1, znode *op2 TSRMLS_DC);
 513 void zend_do_add_variable(znode *result, const znode *op1, const znode *op2 TSRMLS_DC);
 514 
 515 int zend_do_verify_access_types(const znode *current_access_type, const znode *new_modifier);
 516 void zend_do_begin_function_declaration(znode *function_token, znode *function_name, int is_method, int return_reference, znode *fn_flags_znode TSRMLS_DC);
 517 void zend_do_end_function_declaration(const znode *function_token TSRMLS_DC);
 518 void zend_do_receive_param(zend_uchar op, znode *varname, const znode *initialization, znode *class_type, zend_bool pass_by_reference, zend_bool is_variadic TSRMLS_DC);
 519 int zend_do_begin_function_call(znode *function_name, zend_bool check_namespace TSRMLS_DC);
 520 void zend_do_begin_method_call(znode *left_bracket TSRMLS_DC);
 521 void zend_do_clone(znode *result, const znode *expr TSRMLS_DC);
 522 void zend_do_begin_dynamic_function_call(znode *function_name, int prefix_len TSRMLS_DC);
 523 void zend_do_fetch_class(znode *result, znode *class_name TSRMLS_DC);
 524 void zend_do_build_full_name(znode *result, znode *prefix, znode *name, int is_class_member TSRMLS_DC);
 525 int zend_do_begin_class_member_function_call(znode *class_name, znode *method_name TSRMLS_DC);
 526 void zend_do_end_function_call(znode *function_name, znode *result, int is_method, int is_dynamic_fcall TSRMLS_DC);
 527 void zend_do_return(znode *expr, int do_end_vparse TSRMLS_DC);
 528 void zend_do_yield(znode *result, znode *value, const znode *key, zend_bool is_variable TSRMLS_DC);
 529 void zend_do_handle_exception(TSRMLS_D);
 530 
 531 void zend_do_begin_lambda_function_declaration(znode *result, znode *function_token, int return_reference, int is_static TSRMLS_DC);
 532 void zend_do_fetch_lexical_variable(znode *varname, zend_bool is_ref TSRMLS_DC);
 533 
 534 void zend_do_try(znode *try_token TSRMLS_DC);
 535 void zend_do_begin_catch(znode *try_token, znode *catch_class, znode *catch_var, znode *first_catch TSRMLS_DC);
 536 void zend_do_bind_catch(znode *try_token, znode *catch_token TSRMLS_DC);
 537 void zend_do_end_catch(znode *catch_token TSRMLS_DC);
 538 void zend_do_finally(znode *finally_token TSRMLS_DC);
 539 void zend_do_end_finally(znode *try_token, znode* catch_token, znode *finally_token TSRMLS_DC);
 540 void zend_do_throw(const znode *expr TSRMLS_DC);
 541 
 542 ZEND_API int do_bind_function(const zend_op_array *op_array, zend_op *opline, HashTable *function_table, zend_bool compile_time);
 543 ZEND_API zend_class_entry *do_bind_class(const zend_op_array *op_array, const zend_op *opline, HashTable *class_table, zend_bool compile_time TSRMLS_DC);
 544 ZEND_API zend_class_entry *do_bind_inherited_class(const zend_op_array *op_array, const zend_op *opline, HashTable *class_table, zend_class_entry *parent_ce, zend_bool compile_time TSRMLS_DC);
 545 ZEND_API void zend_do_inherit_interfaces(zend_class_entry *ce, const zend_class_entry *iface TSRMLS_DC);
 546 ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry *iface TSRMLS_DC);
 547 void zend_do_implements_interface(znode *interface_znode TSRMLS_DC);
 548 
 549 /* Trait related functions */
 550 void zend_do_use_trait(znode *trait_znode TSRMLS_DC);
 551 void zend_prepare_reference(znode *result, znode *class_name, znode *method_name TSRMLS_DC);
 552 void zend_add_trait_precedence(znode *method_reference, znode *trait_list TSRMLS_DC);
 553 void zend_add_trait_alias(znode *method_reference, znode *modifiers, znode *alias TSRMLS_DC);
 554 
 555 ZEND_API void zend_do_implement_trait(zend_class_entry *ce, zend_class_entry *trait TSRMLS_DC);
 556 ZEND_API void zend_do_bind_traits(zend_class_entry *ce TSRMLS_DC);
 557 
 558 ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce TSRMLS_DC);
 559 void zend_do_early_binding(TSRMLS_D);
 560 ZEND_API void zend_do_delayed_early_binding(const zend_op_array *op_array TSRMLS_DC);
 561 
 562 void zend_do_pass_param(znode *param, zend_uchar op TSRMLS_DC);
 563 void zend_do_unpack_params(znode *params TSRMLS_DC);
 564 
 565 
 566 void zend_do_boolean_or_begin(znode *expr1, znode *op_token TSRMLS_DC);
 567 void zend_do_boolean_or_end(znode *result, const znode *expr1, const znode *expr2, znode *op_token TSRMLS_DC);
 568 void zend_do_boolean_and_begin(znode *expr1, znode *op_token TSRMLS_DC);
 569 void zend_do_boolean_and_end(znode *result, const znode *expr1, const znode *expr2, const znode *op_token TSRMLS_DC);
 570 
 571 void zend_do_brk_cont(zend_uchar op, const znode *expr TSRMLS_DC);
 572 
 573 void zend_do_switch_cond(const znode *cond TSRMLS_DC);
 574 void zend_do_switch_end(const znode *case_list TSRMLS_DC);
 575 void zend_do_case_before_statement(const znode *case_list, znode *case_token, const znode *case_expr TSRMLS_DC);
 576 void zend_do_case_after_statement(znode *result, const znode *case_token TSRMLS_DC);
 577 void zend_do_default_before_statement(const znode *case_list, znode *default_token TSRMLS_DC);
 578 
 579 void zend_do_begin_class_declaration(const znode *class_token, znode *class_name, const znode *parent_class_name TSRMLS_DC);
 580 void zend_do_end_class_declaration(const znode *class_token, const znode *parent_token TSRMLS_DC);
 581 void zend_do_declare_property(const znode *var_name, const znode *value, zend_uint access_type TSRMLS_DC);
 582 void zend_do_declare_class_constant(znode *var_name, const znode *value TSRMLS_DC);
 583 
 584 void zend_do_fetch_property(znode *result, znode *object, const znode *property TSRMLS_DC);
 585 
 586 void zend_do_halt_compiler_register(TSRMLS_D);
 587 
 588 void zend_do_push_object(const znode *object TSRMLS_DC);
 589 void zend_do_pop_object(znode *object TSRMLS_DC);
 590 
 591 
 592 void zend_do_begin_new_object(znode *new_token, znode *class_type TSRMLS_DC);
 593 void zend_do_end_new_object(znode *result, const znode *new_token TSRMLS_DC);
 594 
 595 void zend_do_fetch_constant(znode *result, znode *constant_container, znode *constant_name, int mode, zend_bool check_namespace TSRMLS_DC);
 596 
 597 void zend_do_shell_exec(znode *result, const znode *cmd TSRMLS_DC);
 598 
 599 void zend_do_init_array(znode *result, const znode *expr, const znode *offset, zend_bool is_ref TSRMLS_DC);
 600 void zend_do_add_array_element(znode *result, const znode *expr, const znode *offset, zend_bool is_ref TSRMLS_DC);
 601 void zend_do_add_static_array_element(zval *result, zval *offset, const zval *expr);
 602 void zend_do_list_init(TSRMLS_D);
 603 void zend_do_list_end(znode *result, znode *expr TSRMLS_DC);
 604 void zend_do_add_list_element(const znode *element TSRMLS_DC);
 605 void zend_do_new_list_begin(TSRMLS_D);
 606 void zend_do_new_list_end(TSRMLS_D);
 607 
 608 /* Functions for a null terminated pointer list, used for traits parsing and compilation */
 609 void zend_init_list(void *result, void *item TSRMLS_DC);
 610 void zend_add_to_list(void *result, void *item TSRMLS_DC);
 611 
 612 
 613 void zend_do_cast(znode *result, const znode *expr, int type TSRMLS_DC);
 614 void zend_do_include_or_eval(int type, znode *result, const znode *op1 TSRMLS_DC);
 615 
 616 void zend_do_unset(const znode *variable TSRMLS_DC);
 617 void zend_do_isset_or_isempty(int type, znode *result, znode *variable TSRMLS_DC);
 618 
 619 void zend_do_instanceof(znode *result, const znode *expr, const znode *class_znode, int type TSRMLS_DC);
 620 
 621 void zend_do_foreach_begin(znode *foreach_token, znode *open_brackets_token, znode *array, znode *as_token, int variable TSRMLS_DC);
 622 void zend_do_foreach_cont(znode *foreach_token, const znode *open_brackets_token, const znode *as_token, znode *value, znode *key TSRMLS_DC);
 623 void zend_do_foreach_end(const znode *foreach_token, const znode *as_token TSRMLS_DC);
 624 
 625 void zend_do_declare_begin(TSRMLS_D);
 626 void zend_do_declare_stmt(znode *var, znode *val TSRMLS_DC);
 627 void zend_do_declare_end(const znode *declare_token TSRMLS_DC);
 628 
 629 void zend_do_exit(znode *result, const znode *message TSRMLS_DC);
 630 
 631 void zend_do_begin_silence(znode *strudel_token TSRMLS_DC);
 632 void zend_do_end_silence(const znode *strudel_token TSRMLS_DC);
 633 
 634 void zend_do_jmp_set(const znode *value, znode *jmp_token, znode *colon_token TSRMLS_DC);
 635 void zend_do_jmp_set_else(znode *result, const znode *false_value, const znode *jmp_token, const znode *colon_token TSRMLS_DC);
 636 
 637 void zend_do_begin_qm_op(const znode *cond, znode *qm_token TSRMLS_DC);
 638 void zend_do_qm_true(const znode *true_value, znode *qm_token, znode *colon_token TSRMLS_DC);
 639 void zend_do_qm_false(znode *result, const znode *false_value, const znode *qm_token, const znode *colon_token TSRMLS_DC);
 640 
 641 void zend_do_extended_info(TSRMLS_D);
 642 void zend_do_extended_fcall_begin(TSRMLS_D);
 643 void zend_do_extended_fcall_end(TSRMLS_D);
 644 
 645 void zend_do_ticks(TSRMLS_D);
 646 
 647 void zend_do_abstract_method(const znode *function_name, znode *modifiers, const znode *body TSRMLS_DC);
 648 
 649 void zend_do_declare_constant(znode *name, znode *value TSRMLS_DC);
 650 void zend_do_build_namespace_name(znode *result, znode *prefix, znode *name TSRMLS_DC);
 651 void zend_do_begin_namespace(const znode *name, zend_bool with_brackets TSRMLS_DC);
 652 void zend_do_end_namespace(TSRMLS_D);
 653 void zend_verify_namespace(TSRMLS_D);
 654 void zend_do_use(znode *name, znode *new_name TSRMLS_DC);
 655 void zend_do_use_non_class(znode *ns_name, znode *new_name, int is_function, zend_bool case_sensitive, HashTable *current_import_sub, HashTable *lookup_table TSRMLS_DC);
 656 void zend_do_use_function(znode *name, znode *new_name TSRMLS_DC);
 657 void zend_do_use_const(znode *name, znode *new_name TSRMLS_DC);
 658 void zend_do_end_compilation(TSRMLS_D);
 659 void zend_do_constant_expression(znode *result, zend_ast *ast TSRMLS_DC);
 660 
 661 void zend_do_resolve_class_name(znode *result, znode *class_name, int is_static TSRMLS_DC);
 662 
 663 void zend_do_label(znode *label TSRMLS_DC);
 664 void zend_do_goto(const znode *label TSRMLS_DC);
 665 void zend_resolve_goto_label(zend_op_array *op_array, zend_op *opline, int pass2 TSRMLS_DC);
 666 void zend_release_labels(int temporary TSRMLS_DC);
 667 
 668 ZEND_API void function_add_ref(zend_function *function);
 669 
 670 #define INITIAL_OP_ARRAY_SIZE 64
 671 #define INITIAL_INTERACTIVE_OP_ARRAY_SIZE 8192
 672 
 673 
 674 /* helper functions in zend_language_scanner.l */
 675 ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type TSRMLS_DC);
 676 ZEND_API zend_op_array *compile_string(zval *source_string, char *filename TSRMLS_DC);
 677 ZEND_API zend_op_array *compile_filename(int type, zval *filename TSRMLS_DC);
 678 ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval **retval, int file_count, ...);
 679 ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC);
 680 ZEND_API void init_op_array(zend_op_array *op_array, zend_uchar type, int initial_ops_size TSRMLS_DC);
 681 ZEND_API void destroy_op_array(zend_op_array *op_array TSRMLS_DC);
 682 ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle TSRMLS_DC);
 683 ZEND_API int zend_cleanup_class_data(zend_class_entry **pce TSRMLS_DC);
 684 ZEND_API int zend_cleanup_user_class_data(zend_class_entry **pce TSRMLS_DC);
 685 ZEND_API void zend_cleanup_internal_class_data(zend_class_entry *ce TSRMLS_DC);
 686 ZEND_API void zend_cleanup_internal_classes(TSRMLS_D);
 687 ZEND_API int zend_cleanup_function_data(zend_function *function TSRMLS_DC);
 688 ZEND_API int zend_cleanup_function_data_full(zend_function *function TSRMLS_DC);
 689 ZEND_API int clean_non_persistent_function_full(zend_function *function TSRMLS_DC);
 690 ZEND_API int clean_non_persistent_class_full(zend_class_entry **ce TSRMLS_DC);
 691 
 692 ZEND_API void destroy_zend_function(zend_function *function TSRMLS_DC);
 693 ZEND_API void zend_function_dtor(zend_function *function);
 694 ZEND_API void destroy_zend_class(zend_class_entry **pce);
 695 void zend_class_add_ref(zend_class_entry **ce);
 696 
 697 ZEND_API void zend_mangle_property_name(char **dest, int *dest_length, const char *src1, int src1_length, const char *src2, int src2_length, int internal);
 698 #define zend_unmangle_property_name(mangled_property, mangled_property_len, class_name, prop_name) \
 699         zend_unmangle_property_name_ex(mangled_property, mangled_property_len, class_name, prop_name, NULL)
 700 ZEND_API int zend_unmangle_property_name_ex(const char *mangled_property, int mangled_property_len, const char **class_name, const char **prop_name, int *prop_len);
 701 
 702 #define ZEND_FUNCTION_DTOR (void (*)(void *)) zend_function_dtor
 703 #define ZEND_CLASS_DTOR (void (*)(void *)) destroy_zend_class
 704 
 705 zend_op *get_next_op(zend_op_array *op_array TSRMLS_DC);
 706 void init_op(zend_op *op TSRMLS_DC);
 707 int get_next_op_number(zend_op_array *op_array);
 708 int print_class(zend_class_entry *class_entry TSRMLS_DC);
 709 void print_op_array(zend_op_array *op_array, int optimizations);
 710 ZEND_API int pass_two(zend_op_array *op_array TSRMLS_DC);
 711 zend_brk_cont_element *get_next_brk_cont_element(zend_op_array *op_array);
 712 void zend_do_first_catch(znode *open_parentheses TSRMLS_DC);
 713 void zend_initialize_try_catch_element(znode *catch_token TSRMLS_DC);
 714 void zend_do_mark_last_catch(const znode *first_catch, const znode *last_additional_catch TSRMLS_DC);
 715 ZEND_API zend_bool zend_is_compiling(TSRMLS_D);
 716 ZEND_API char *zend_make_compiled_string_description(const char *name TSRMLS_DC);
 717 ZEND_API void zend_initialize_class_data(zend_class_entry *ce, zend_bool nullify_handlers TSRMLS_DC);
 718 int zend_get_class_fetch_type(const char *class_name, uint class_name_len);
 719 
 720 typedef zend_bool (*zend_auto_global_callback)(const char *name, uint name_len TSRMLS_DC);
 721 typedef struct _zend_auto_global {
 722         const char *name;
 723         uint name_len;
 724         zend_auto_global_callback auto_global_callback;
 725         zend_bool jit;
 726         zend_bool armed;
 727 } zend_auto_global;
 728 
 729 ZEND_API int zend_register_auto_global(const char *name, uint name_len, zend_bool jit, zend_auto_global_callback auto_global_callback TSRMLS_DC);
 730 ZEND_API void zend_activate_auto_globals(TSRMLS_D);
 731 ZEND_API zend_bool zend_is_auto_global(const char *name, uint name_len TSRMLS_DC);
 732 ZEND_API zend_bool zend_is_auto_global_quick(const char *name, uint name_len, ulong hashval TSRMLS_DC);
 733 ZEND_API size_t zend_dirname(char *path, size_t len);
 734 
 735 int zendlex(znode *zendlval TSRMLS_DC);
 736 
 737 int zend_add_literal(zend_op_array *op_array, const zval *zv TSRMLS_DC);
 738 
 739 /* BEGIN: OPCODES */
 740 
 741 #include "zend_vm_opcodes.h"
 742 
 743 #define ZEND_OP_DATA                            137
 744 
 745 /* END: OPCODES */
 746 
 747 /* class fetches */
 748 #define ZEND_FETCH_CLASS_DEFAULT        0
 749 #define ZEND_FETCH_CLASS_SELF           1
 750 #define ZEND_FETCH_CLASS_PARENT         2
 751 #define ZEND_FETCH_CLASS_MAIN           3       /* unused */
 752 #define ZEND_FETCH_CLASS_GLOBAL         4       /* unused */
 753 #define ZEND_FETCH_CLASS_AUTO           5
 754 #define ZEND_FETCH_CLASS_INTERFACE      6
 755 #define ZEND_FETCH_CLASS_STATIC         7
 756 #define ZEND_FETCH_CLASS_TRAIT          14
 757 #define ZEND_FETCH_CLASS_MASK        0x0f
 758 #define ZEND_FETCH_CLASS_NO_AUTOLOAD 0x80
 759 #define ZEND_FETCH_CLASS_SILENT      0x0100
 760 
 761 /* variable parsing type (compile-time) */
 762 #define ZEND_PARSED_MEMBER                              (1<<0)
 763 #define ZEND_PARSED_METHOD_CALL                 (1<<1)
 764 #define ZEND_PARSED_STATIC_MEMBER               (1<<2)
 765 #define ZEND_PARSED_FUNCTION_CALL               (1<<3)
 766 #define ZEND_PARSED_VARIABLE                    (1<<4)
 767 #define ZEND_PARSED_REFERENCE_VARIABLE  (1<<5)
 768 #define ZEND_PARSED_NEW                                 (1<<6)
 769 #define ZEND_PARSED_LIST_EXPR                   (1<<7)
 770 
 771 
 772 /* unset types */
 773 #define ZEND_UNSET_REG 0
 774 
 775 /* var status for backpatching */
 776 #define BP_VAR_R                        0
 777 #define BP_VAR_W                        1
 778 #define BP_VAR_RW                       2
 779 #define BP_VAR_IS                       3
 780 #define BP_VAR_NA                       4       /* if not applicable */
 781 #define BP_VAR_FUNC_ARG         5
 782 #define BP_VAR_UNSET            6
 783 
 784 
 785 #define ZEND_INTERNAL_FUNCTION                          1
 786 #define ZEND_USER_FUNCTION                                      2
 787 #define ZEND_OVERLOADED_FUNCTION                        3
 788 #define ZEND_EVAL_CODE                                          4
 789 #define ZEND_OVERLOADED_FUNCTION_TEMPORARY      5
 790 
 791 #define ZEND_INTERNAL_CLASS         1
 792 #define ZEND_USER_CLASS             2
 793 
 794 #define ZEND_EVAL                               (1<<0)
 795 #define ZEND_INCLUDE                    (1<<1)
 796 #define ZEND_INCLUDE_ONCE               (1<<2)
 797 #define ZEND_REQUIRE                    (1<<3)
 798 #define ZEND_REQUIRE_ONCE               (1<<4)
 799 
 800 #define ZEND_CT (1<<0)
 801 #define ZEND_RT (1<<1)
 802 
 803 /* global/local fetches */
 804 #define ZEND_FETCH_GLOBAL                       0x00000000
 805 #define ZEND_FETCH_LOCAL                        0x10000000
 806 #define ZEND_FETCH_STATIC                       0x20000000
 807 #define ZEND_FETCH_STATIC_MEMBER        0x30000000
 808 #define ZEND_FETCH_GLOBAL_LOCK          0x40000000
 809 #define ZEND_FETCH_LEXICAL                      0x50000000
 810 
 811 #define ZEND_FETCH_TYPE_MASK            0x70000000
 812 
 813 #define ZEND_FETCH_STANDARD                 0x00000000
 814 #define ZEND_FETCH_ADD_LOCK                 0x08000000
 815 #define ZEND_FETCH_MAKE_REF                 0x04000000
 816 
 817 #define ZEND_ISSET                                  0x02000000
 818 #define ZEND_ISEMPTY                        0x01000000
 819 #define ZEND_ISSET_ISEMPTY_MASK     (ZEND_ISSET | ZEND_ISEMPTY)
 820 #define ZEND_QUICK_SET                      0x00800000
 821 
 822 #define ZEND_FETCH_ARG_MASK         0x000fffff
 823 
 824 #define ZEND_FE_FETCH_BYREF     1
 825 #define ZEND_FE_FETCH_WITH_KEY  2
 826 
 827 #define ZEND_FE_RESET_VARIABLE          (1<<0)
 828 #define ZEND_FE_RESET_REFERENCE         (1<<1)
 829 #define EXT_TYPE_FREE_ON_RETURN         (1<<2)
 830 
 831 #define ZEND_MEMBER_FUNC_CALL   1<<0
 832 
 833 #define ZEND_ARG_SEND_BY_REF (1<<0)
 834 #define ZEND_ARG_COMPILE_TIME_BOUND (1<<1)
 835 #define ZEND_ARG_SEND_FUNCTION (1<<2)
 836 #define ZEND_ARG_SEND_SILENT   (1<<3)
 837 
 838 #define ZEND_SEND_BY_VAL     0
 839 #define ZEND_SEND_BY_REF     1
 840 #define ZEND_SEND_PREFER_REF 2
 841 
 842 #define CHECK_ARG_SEND_TYPE(zf, arg_num, m) \
 843         ((zf)->common.arg_info && \
 844         (arg_num <= (zf)->common.num_args \
 845                 ? ((zf)->common.arg_info[arg_num-1].pass_by_reference & (m)) \
 846                 : ((zf)->common.fn_flags & ZEND_ACC_VARIADIC) \
 847                         ? ((zf)->common.arg_info[(zf)->common.num_args-1].pass_by_reference & (m)) : 0))
 848 
 849 #define ARG_MUST_BE_SENT_BY_REF(zf, arg_num) \
 850         CHECK_ARG_SEND_TYPE(zf, arg_num, ZEND_SEND_BY_REF)
 851 
 852 #define ARG_SHOULD_BE_SENT_BY_REF(zf, arg_num) \
 853         CHECK_ARG_SEND_TYPE(zf, arg_num, ZEND_SEND_BY_REF|ZEND_SEND_PREFER_REF)
 854 
 855 #define ARG_MAY_BE_SENT_BY_REF(zf, arg_num) \
 856         CHECK_ARG_SEND_TYPE(zf, arg_num, ZEND_SEND_PREFER_REF)
 857 
 858 #define ZEND_RETURN_VAL 0
 859 #define ZEND_RETURN_REF 1
 860 
 861 
 862 #define ZEND_RETURNS_FUNCTION 1<<0
 863 #define ZEND_RETURNS_NEW      1<<1
 864 #define ZEND_RETURNS_VALUE    1<<2
 865 
 866 #define ZEND_FAST_RET_TO_CATCH          1
 867 #define ZEND_FAST_RET_TO_FINALLY        2
 868 
 869 #define ZEND_FAST_CALL_FROM_CATCH       1
 870 #define ZEND_FAST_CALL_FROM_FINALLY     2
 871 
 872 END_EXTERN_C()
 873 
 874 #define ZEND_CLONE_FUNC_NAME            "__clone"
 875 #define ZEND_CONSTRUCTOR_FUNC_NAME      "__construct"
 876 #define ZEND_DESTRUCTOR_FUNC_NAME       "__destruct"
 877 #define ZEND_GET_FUNC_NAME          "__get"
 878 #define ZEND_SET_FUNC_NAME          "__set"
 879 #define ZEND_UNSET_FUNC_NAME        "__unset"
 880 #define ZEND_ISSET_FUNC_NAME        "__isset"
 881 #define ZEND_CALL_FUNC_NAME         "__call"
 882 #define ZEND_CALLSTATIC_FUNC_NAME   "__callstatic"
 883 #define ZEND_TOSTRING_FUNC_NAME     "__tostring"
 884 #define ZEND_AUTOLOAD_FUNC_NAME     "__autoload"
 885 #define ZEND_INVOKE_FUNC_NAME       "__invoke"
 886 #define ZEND_DEBUGINFO_FUNC_NAME    "__debuginfo"
 887 
 888 /* The following constants may be combined in CG(compiler_options)
 889  * to change the default compiler behavior */
 890 
 891 /* generate extended debug information */
 892 #define ZEND_COMPILE_EXTENDED_INFO                              (1<<0)
 893 
 894 /* call op_array handler of extendions */
 895 #define ZEND_COMPILE_HANDLE_OP_ARRAY            (1<<1)
 896 
 897 /* generate ZEND_DO_FCALL_BY_NAME for internal functions instead of ZEND_DO_FCALL */
 898 #define ZEND_COMPILE_IGNORE_INTERNAL_FUNCTIONS  (1<<2)
 899 
 900 /* don't perform early binding for classes inherited form internal ones;
 901  * in namespaces assume that internal class that doesn't exist at compile-time
 902  * may apper in run-time */
 903 #define ZEND_COMPILE_IGNORE_INTERNAL_CLASSES    (1<<3)
 904 
 905 /* generate ZEND_DECLARE_INHERITED_CLASS_DELAYED opcode to delay early binding */
 906 #define ZEND_COMPILE_DELAYED_BINDING                    (1<<4)
 907 
 908 /* disable constant substitution at compile-time */
 909 #define ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION   (1<<5)
 910 
 911 /* The default value for CG(compiler_options) */
 912 #define ZEND_COMPILE_DEFAULT                                    ZEND_COMPILE_HANDLE_OP_ARRAY
 913 
 914 /* The default value for CG(compiler_options) during eval() */
 915 #define ZEND_COMPILE_DEFAULT_FOR_EVAL                   0
 916 
 917 #endif /* ZEND_COMPILE_H */
 918 
 919 /*
 920  * Local variables:
 921  * tab-width: 4
 922  * c-basic-offset: 4
 923  * indent-tabs-mode: t
 924  * End:
 925  */

/* [<][>][^][v][top][bottom][index][help] */