Back to index

php5  5.3.10
zend_compile.h
Go to the documentation of this file.
00001 /*
00002    +----------------------------------------------------------------------+
00003    | Zend Engine                                                          |
00004    +----------------------------------------------------------------------+
00005    | Copyright (c) 1998-2012 Zend Technologies Ltd. (http://www.zend.com) |
00006    +----------------------------------------------------------------------+
00007    | This source file is subject to version 2.00 of the Zend license,     |
00008    | that is bundled with this package in the file LICENSE, and is        |
00009    | available through the world-wide-web at the following url:           |
00010    | http://www.zend.com/license/2_00.txt.                                |
00011    | If you did not receive a copy of the Zend license and are unable to  |
00012    | obtain it through the world-wide-web, please send a note to          |
00013    | license@zend.com so we can mail you a copy immediately.              |
00014    +----------------------------------------------------------------------+
00015    | Authors: Andi Gutmans <andi@zend.com>                                |
00016    |          Zeev Suraski <zeev@zend.com>                                |
00017    +----------------------------------------------------------------------+
00018 */
00019 
00020 /* $Id: zend_compile.h 321634 2012-01-01 13:15:04Z felipe $ */
00021 
00022 #ifndef ZEND_COMPILE_H
00023 #define ZEND_COMPILE_H
00024 
00025 #include "zend.h"
00026 
00027 #ifdef HAVE_STDARG_H
00028 # include <stdarg.h>
00029 #endif
00030 
00031 #include "zend_llist.h"
00032 
00033 #define DEBUG_ZEND 0
00034 
00035 #define FREE_PNODE(znode)   zval_dtor(&znode->u.constant);
00036 
00037 #define SET_UNUSED(op)  (op).op_type = IS_UNUSED
00038 
00039 #define INC_BPC(op_array)   if (op_array->fn_flags & ZEND_ACC_INTERACTIVE) { ((op_array)->backpatch_count++); }
00040 #define DEC_BPC(op_array)   if (op_array->fn_flags & ZEND_ACC_INTERACTIVE) { ((op_array)->backpatch_count--); }
00041 #define HANDLE_INTERACTIVE()  if (CG(active_op_array)->fn_flags & ZEND_ACC_INTERACTIVE) { execute_new_code(TSRMLS_C); }
00042 #define DO_TICKS()            if (Z_LVAL(CG(declarables).ticks)) { zend_do_ticks(TSRMLS_C); }
00043 
00044 #define RESET_DOC_COMMENT()        \
00045     {                              \
00046         if (CG(doc_comment)) {     \
00047           efree(CG(doc_comment));  \
00048           CG(doc_comment) = NULL;  \
00049         }                          \
00050         CG(doc_comment_len) = 0;   \
00051     }
00052 
00053 typedef struct _zend_op_array zend_op_array;
00054 typedef struct _zend_op zend_op;
00055 
00056 typedef struct _znode {
00057        int op_type;
00058        union {
00059               zval constant;
00060 
00061               zend_uint var;
00062               zend_uint opline_num; /*  Needs to be signed */
00063               zend_op_array *op_array;
00064               zend_op *jmp_addr;
00065               struct {
00066                      zend_uint var;       /* dummy */
00067                      zend_uint type;
00068               } EA;
00069        } u;
00070 } znode;
00071 
00072 typedef struct _zend_execute_data zend_execute_data;
00073 
00074 #define ZEND_OPCODE_HANDLER_ARGS zend_execute_data *execute_data TSRMLS_DC
00075 #define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU execute_data TSRMLS_CC
00076 
00077 typedef int (*user_opcode_handler_t) (ZEND_OPCODE_HANDLER_ARGS);
00078 typedef int (ZEND_FASTCALL *opcode_handler_t) (ZEND_OPCODE_HANDLER_ARGS);
00079 
00080 extern ZEND_API opcode_handler_t *zend_opcode_handlers;
00081 
00082 struct _zend_op {
00083        opcode_handler_t handler;
00084        znode result;
00085        znode op1;
00086        znode op2;
00087        ulong extended_value;
00088        uint lineno;
00089        zend_uchar opcode;
00090 };
00091 
00092 
00093 typedef struct _zend_brk_cont_element {
00094        int start;
00095        int cont;
00096        int brk;
00097        int parent;
00098 } zend_brk_cont_element;
00099 
00100 typedef struct _zend_label {
00101        int brk_cont;
00102        zend_uint opline_num;
00103 } zend_label;
00104 
00105 typedef struct _zend_try_catch_element {
00106        zend_uint try_op;
00107        zend_uint catch_op;  /* ketchup! */
00108 } zend_try_catch_element;
00109 
00110 
00111 /* method flags (types) */
00112 #define ZEND_ACC_STATIC                   0x01
00113 #define ZEND_ACC_ABSTRACT          0x02
00114 #define ZEND_ACC_FINAL                    0x04
00115 #define ZEND_ACC_IMPLEMENTED_ABSTRACT            0x08
00116 
00117 /* class flags (types) */
00118 /* 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). */
00119 /* ZEND_ACC_EXPLICIT_ABSTRACT_CLASS denotes that a class was explicitly defined as abstract by using the keyword. */
00120 #define ZEND_ACC_IMPLICIT_ABSTRACT_CLASS  0x10
00121 #define ZEND_ACC_EXPLICIT_ABSTRACT_CLASS  0x20
00122 #define ZEND_ACC_FINAL_CLASS                   0x40
00123 #define ZEND_ACC_INTERFACE                     0x80
00124 
00125 /* op_array flags */
00126 #define ZEND_ACC_INTERACTIVE                            0x10
00127 
00128 /* method flags (visibility) */
00129 /* The order of those must be kept - public < protected < private */
00130 #define ZEND_ACC_PUBLIC            0x100
00131 #define ZEND_ACC_PROTECTED  0x200
00132 #define ZEND_ACC_PRIVATE    0x400
00133 #define ZEND_ACC_PPP_MASK  (ZEND_ACC_PUBLIC | ZEND_ACC_PROTECTED | ZEND_ACC_PRIVATE)
00134 
00135 #define ZEND_ACC_CHANGED    0x800
00136 #define ZEND_ACC_IMPLICIT_PUBLIC   0x1000
00137 
00138 /* method flags (special method detection) */
00139 #define ZEND_ACC_CTOR              0x2000
00140 #define ZEND_ACC_DTOR              0x4000
00141 #define ZEND_ACC_CLONE             0x8000
00142 
00143 /* method flag (bc only), any method that has this flag can be used statically and non statically. */
00144 #define ZEND_ACC_ALLOW_STATIC      0x10000
00145 
00146 /* shadow of parent's private method/property */
00147 #define ZEND_ACC_SHADOW 0x20000
00148 
00149 /* deprecation flag */
00150 #define ZEND_ACC_DEPRECATED 0x40000
00151 
00152 /* class implement interface(s) flag */
00153 #define ZEND_ACC_IMPLEMENT_INTERFACES 0x80000
00154 
00155 #define ZEND_ACC_CLOSURE              0x100000
00156 
00157 /* function flag for internal user call handlers __call, __callstatic */
00158 #define ZEND_ACC_CALL_VIA_HANDLER     0x200000
00159 
00160 char *zend_visibility_string(zend_uint fn_flags);
00161 
00162 
00163 typedef struct _zend_property_info {
00164        zend_uint flags;
00165        char *name;
00166        int name_length;
00167        ulong h;
00168        char *doc_comment;
00169        int doc_comment_len;
00170        zend_class_entry *ce;
00171 } zend_property_info;
00172 
00173 
00174 typedef struct _zend_arg_info {
00175        const char *name;
00176        zend_uint name_len;
00177        const char *class_name;
00178        zend_uint class_name_len;
00179        zend_bool array_type_hint;
00180        zend_bool allow_null;
00181        zend_bool pass_by_reference;
00182        zend_bool return_reference;
00183        int required_num_args;
00184 } zend_arg_info;
00185 
00186 typedef struct _zend_compiled_variable {
00187        char *name;
00188        int name_len;
00189        ulong hash_value;
00190 } zend_compiled_variable;
00191 
00192 struct _zend_op_array {
00193        /* Common elements */
00194        zend_uchar type;
00195        char *function_name;        
00196        zend_class_entry *scope;
00197        zend_uint fn_flags;
00198        union _zend_function *prototype;
00199        zend_uint num_args;
00200        zend_uint required_num_args;
00201        zend_arg_info *arg_info;
00202        zend_bool pass_rest_by_reference;
00203        unsigned char return_reference;
00204        /* END of common elements */
00205 
00206        zend_bool done_pass_two;
00207 
00208        zend_uint *refcount;
00209 
00210        zend_op *opcodes;
00211        zend_uint last, size;
00212 
00213        zend_compiled_variable *vars;
00214        int last_var, size_var;
00215 
00216        zend_uint T;
00217 
00218        zend_brk_cont_element *brk_cont_array;
00219        int last_brk_cont;
00220        int current_brk_cont;
00221 
00222        zend_try_catch_element *try_catch_array;
00223        int last_try_catch;
00224 
00225        /* static variables support */
00226        HashTable *static_variables;
00227 
00228        zend_op *start_op;
00229        int backpatch_count;
00230 
00231        zend_uint this_var;
00232 
00233        char *filename;
00234        zend_uint line_start;
00235        zend_uint line_end;
00236        char *doc_comment;
00237        zend_uint doc_comment_len;
00238        zend_uint early_binding; /* the linked list of delayed declarations */
00239 
00240        void *reserved[ZEND_MAX_RESERVED_RESOURCES];
00241 };
00242 
00243 
00244 #define ZEND_RETURN_VALUE                        0
00245 #define ZEND_RETURN_REFERENCE                    1
00246 
00247 typedef struct _zend_internal_function {
00248        /* Common elements */
00249        zend_uchar type;
00250        char * function_name;
00251        zend_class_entry *scope;
00252        zend_uint fn_flags;
00253        union _zend_function *prototype;
00254        zend_uint num_args;
00255        zend_uint required_num_args;
00256        zend_arg_info *arg_info;
00257        zend_bool pass_rest_by_reference;
00258        unsigned char return_reference;
00259        /* END of common elements */
00260 
00261        void (*handler)(INTERNAL_FUNCTION_PARAMETERS);
00262        struct _zend_module_entry *module;
00263 } zend_internal_function;
00264 
00265 #define ZEND_FN_SCOPE_NAME(function)  ((function) && (function)->common.scope ? (function)->common.scope->name : "")
00266 
00267 typedef union _zend_function {
00268        zend_uchar type;     /* MUST be the first element of this struct! */
00269 
00270        struct {
00271               zend_uchar type;  /* never used */
00272               char *function_name;
00273               zend_class_entry *scope;
00274               zend_uint fn_flags;
00275               union _zend_function *prototype;
00276               zend_uint num_args;
00277               zend_uint required_num_args;
00278               zend_arg_info *arg_info;
00279               zend_bool pass_rest_by_reference;
00280               unsigned char return_reference;
00281        } common;
00282 
00283        zend_op_array op_array;
00284        zend_internal_function internal_function;
00285 } zend_function;
00286 
00287 
00288 typedef struct _zend_function_state {
00289        zend_function *function;
00290        void **arguments;
00291 } zend_function_state;
00292 
00293 
00294 typedef struct _zend_switch_entry {
00295        znode cond;
00296        int default_case;
00297        int control_var;
00298 } zend_switch_entry;
00299 
00300 
00301 typedef struct _list_llist_element {
00302        znode var;
00303        zend_llist dimensions;
00304        znode value;
00305 } list_llist_element;
00306 
00307 union _temp_variable;
00308 
00309 struct _zend_execute_data {
00310        struct _zend_op *opline;
00311        zend_function_state function_state;
00312        zend_function *fbc; /* Function Being Called */
00313        zend_class_entry *called_scope;
00314        zend_op_array *op_array;
00315        zval *object;
00316        union _temp_variable *Ts;
00317        zval ***CVs;
00318        HashTable *symbol_table;
00319        struct _zend_execute_data *prev_execute_data;
00320        zval *old_error_reporting;
00321        zend_bool nested;
00322        zval **original_return_value;
00323        zend_class_entry *current_scope;
00324        zend_class_entry *current_called_scope;
00325        zval *current_this;
00326        zval *current_object;
00327        struct _zend_op *call_opline;
00328 };
00329 
00330 #define EX(element) execute_data.element
00331 
00332 
00333 #define IS_CONST     (1<<0)
00334 #define IS_TMP_VAR   (1<<1)
00335 #define IS_VAR              (1<<2)
00336 #define IS_UNUSED    (1<<3) /* Unused variable */
00337 #define IS_CV        (1<<4) /* Compiled variable */
00338 
00339 #define EXT_TYPE_UNUSED                          (1<<0)
00340 #define EXT_TYPE_FREE_ON_RETURN           (2<<0)
00341 
00342 #include "zend_globals.h"
00343 
00344 BEGIN_EXTERN_C()
00345 
00346 void init_compiler(TSRMLS_D);
00347 void shutdown_compiler(TSRMLS_D);
00348 void zend_init_compiler_data_structures(TSRMLS_D);
00349 
00350 extern ZEND_API zend_op_array *(*zend_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC);
00351 extern ZEND_API zend_op_array *(*zend_compile_string)(zval *source_string, char *filename TSRMLS_DC);
00352 
00353 ZEND_API int lex_scan(zval *zendlval TSRMLS_DC);
00354 void startup_scanner(TSRMLS_D);
00355 void shutdown_scanner(TSRMLS_D);
00356 
00357 ZEND_API char *zend_set_compiled_filename(const char *new_compiled_filename TSRMLS_DC);
00358 ZEND_API void zend_restore_compiled_filename(char *original_compiled_filename TSRMLS_DC);
00359 ZEND_API char *zend_get_compiled_filename(TSRMLS_D);
00360 ZEND_API int zend_get_compiled_lineno(TSRMLS_D);
00361 ZEND_API size_t zend_get_scanned_file_offset(TSRMLS_D);
00362 
00363 void zend_resolve_non_class_name(znode *element_name, zend_bool check_namespace TSRMLS_DC);
00364 void zend_resolve_class_name(znode *class_name, ulong *fetch_type, int check_ns_name TSRMLS_DC);
00365 ZEND_API char* zend_get_compiled_variable_name(const zend_op_array *op_array, zend_uint var, int* name_len);
00366 
00367 #ifdef ZTS
00368 const char *zend_get_zendtext(TSRMLS_D);
00369 int zend_get_zendleng(TSRMLS_D);
00370 #endif
00371 
00372 
00373 /* parser-driven code generators */
00374 void zend_do_binary_op(zend_uchar op, znode *result, const znode *op1, const znode *op2 TSRMLS_DC);
00375 void zend_do_unary_op(zend_uchar op, znode *result, const znode *op1 TSRMLS_DC);
00376 void zend_do_binary_assign_op(zend_uchar op, znode *result, const znode *op1, const znode *op2 TSRMLS_DC);
00377 void zend_do_assign(znode *result, znode *variable, const znode *value TSRMLS_DC);
00378 void zend_do_assign_ref(znode *result, const znode *lvar, const znode *rvar TSRMLS_DC);
00379 void fetch_simple_variable(znode *result, znode *varname, int bp TSRMLS_DC);
00380 void fetch_simple_variable_ex(znode *result, znode *varname, int bp, zend_uchar op TSRMLS_DC);
00381 void zend_do_indirect_references(znode *result, const znode *num_references, znode *variable TSRMLS_DC);
00382 void zend_do_fetch_static_variable(znode *varname, const znode *static_assignment, int fetch_type TSRMLS_DC);
00383 void zend_do_fetch_global_variable(znode *varname, const znode *static_assignment, int fetch_type TSRMLS_DC);
00384 
00385 void fetch_array_begin(znode *result, znode *varname, znode *first_dim TSRMLS_DC);
00386 void fetch_array_dim(znode *result, const znode *parent, const znode *dim TSRMLS_DC);
00387 void fetch_string_offset(znode *result, const znode *parent, const znode *offset TSRMLS_DC);
00388 void zend_do_fetch_static_member(znode *result, znode *class_znode TSRMLS_DC);
00389 void zend_do_print(znode *result, const znode *arg TSRMLS_DC);
00390 void zend_do_echo(const znode *arg TSRMLS_DC);
00391 typedef int (*unary_op_type)(zval *, zval * TSRMLS_DC);
00392 typedef int (*binary_op_type)(zval *, zval *, zval * TSRMLS_DC);
00393 ZEND_API unary_op_type get_unary_op(int opcode);
00394 ZEND_API binary_op_type get_binary_op(int opcode);
00395 
00396 void zend_do_while_cond(const znode *expr, znode *close_bracket_token TSRMLS_DC);
00397 void zend_do_while_end(const znode *while_token, const znode *close_bracket_token TSRMLS_DC);
00398 void zend_do_do_while_begin(TSRMLS_D);
00399 void zend_do_do_while_end(const znode *do_token, const znode *expr_open_bracket, const znode *expr TSRMLS_DC);
00400 
00401 
00402 void zend_do_if_cond(const znode *cond, znode *closing_bracket_token TSRMLS_DC);
00403 void zend_do_if_after_statement(const znode *closing_bracket_token, unsigned char initialize TSRMLS_DC);
00404 void zend_do_if_end(TSRMLS_D);
00405 
00406 void zend_do_for_cond(const znode *expr, znode *second_semicolon_token TSRMLS_DC);
00407 void zend_do_for_before_statement(const znode *cond_start, const znode *second_semicolon_token TSRMLS_DC);
00408 void zend_do_for_end(const znode *second_semicolon_token TSRMLS_DC);
00409 
00410 void zend_do_pre_incdec(znode *result, const znode *op1, zend_uchar op TSRMLS_DC);
00411 void zend_do_post_incdec(znode *result, const znode *op1, zend_uchar op TSRMLS_DC);
00412 
00413 void zend_do_begin_variable_parse(TSRMLS_D);
00414 void zend_do_end_variable_parse(znode *variable, int type, int arg_offset TSRMLS_DC);
00415 
00416 void zend_check_writable_variable(const znode *variable);
00417 
00418 void zend_do_free(znode *op1 TSRMLS_DC);
00419 
00420 void zend_do_add_string(znode *result, const znode *op1, znode *op2 TSRMLS_DC);
00421 void zend_do_add_variable(znode *result, const znode *op1, const znode *op2 TSRMLS_DC);
00422 
00423 int zend_do_verify_access_types(const znode *current_access_type, const znode *new_modifier);
00424 void zend_do_begin_function_declaration(znode *function_token, znode *function_name, int is_method, int return_reference, znode *fn_flags_znode TSRMLS_DC);
00425 void zend_do_end_function_declaration(const znode *function_token TSRMLS_DC);
00426 void zend_do_receive_arg(zend_uchar op, const znode *var, const znode *offset, const znode *initialization, znode *class_type, const znode *varname, zend_bool pass_by_reference TSRMLS_DC);
00427 int zend_do_begin_function_call(znode *function_name, zend_bool check_namespace TSRMLS_DC);
00428 void zend_do_begin_method_call(znode *left_bracket TSRMLS_DC);
00429 void zend_do_clone(znode *result, const znode *expr TSRMLS_DC);
00430 void zend_do_begin_dynamic_function_call(znode *function_name, int prefix_len TSRMLS_DC);
00431 void zend_do_fetch_class(znode *result, znode *class_name TSRMLS_DC);
00432 void zend_do_build_full_name(znode *result, znode *prefix, znode *name, int is_class_member TSRMLS_DC);
00433 int zend_do_begin_class_member_function_call(znode *class_name, znode *method_name TSRMLS_DC);
00434 void zend_do_end_function_call(znode *function_name, znode *result, const znode *argument_list, int is_method, int is_dynamic_fcall TSRMLS_DC);
00435 void zend_do_return(znode *expr, int do_end_vparse TSRMLS_DC);
00436 void zend_do_handle_exception(TSRMLS_D);
00437 
00438 void zend_do_begin_lambda_function_declaration(znode *result, znode *function_token, int return_reference TSRMLS_DC);
00439 void zend_do_fetch_lexical_variable(znode *varname, zend_bool is_ref TSRMLS_DC);
00440 
00441 void zend_do_try(znode *try_token TSRMLS_DC);
00442 void zend_do_begin_catch(znode *try_token, znode *catch_class, const znode *catch_var, znode *first_catch TSRMLS_DC);
00443 void zend_do_end_catch(const znode *try_token TSRMLS_DC);
00444 void zend_do_throw(const znode *expr TSRMLS_DC);
00445 
00446 ZEND_API int do_bind_function(zend_op *opline, HashTable *function_table, zend_bool compile_time);
00447 ZEND_API zend_class_entry *do_bind_class(const zend_op *opline, HashTable *class_table, zend_bool compile_time TSRMLS_DC);
00448 ZEND_API zend_class_entry *do_bind_inherited_class(const zend_op *opline, HashTable *class_table, zend_class_entry *parent_ce, zend_bool compile_time TSRMLS_DC);
00449 ZEND_API void zend_do_inherit_interfaces(zend_class_entry *ce, const zend_class_entry *iface TSRMLS_DC);
00450 ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry *iface TSRMLS_DC);
00451 void zend_do_implements_interface(znode *interface_znode TSRMLS_DC);
00452 
00453 ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce TSRMLS_DC);
00454 void zend_do_early_binding(TSRMLS_D);
00455 ZEND_API void zend_do_delayed_early_binding(const zend_op_array *op_array TSRMLS_DC);
00456 
00457 void zend_do_pass_param(znode *param, zend_uchar op, int offset TSRMLS_DC);
00458 
00459 
00460 void zend_do_boolean_or_begin(znode *expr1, znode *op_token TSRMLS_DC);
00461 void zend_do_boolean_or_end(znode *result, const znode *expr1, const znode *expr2, znode *op_token TSRMLS_DC);
00462 void zend_do_boolean_and_begin(znode *expr1, znode *op_token TSRMLS_DC);
00463 void zend_do_boolean_and_end(znode *result, const znode *expr1, const znode *expr2, const znode *op_token TSRMLS_DC);
00464 
00465 void zend_do_brk_cont(zend_uchar op, const znode *expr TSRMLS_DC);
00466 
00467 void zend_do_switch_cond(const znode *cond TSRMLS_DC);
00468 void zend_do_switch_end(const znode *case_list TSRMLS_DC);
00469 void zend_do_case_before_statement(const znode *case_list, znode *case_token, const znode *case_expr TSRMLS_DC);
00470 void zend_do_case_after_statement(znode *result, const znode *case_token TSRMLS_DC);
00471 void zend_do_default_before_statement(const znode *case_list, znode *default_token TSRMLS_DC);
00472 
00473 void zend_do_begin_class_declaration(const znode *class_token, znode *class_name, const znode *parent_class_name TSRMLS_DC);
00474 void zend_do_end_class_declaration(const znode *class_token, const znode *parent_token TSRMLS_DC);
00475 void zend_do_declare_property(const znode *var_name, const znode *value, zend_uint access_type TSRMLS_DC);
00476 void zend_do_declare_implicit_property(TSRMLS_D);
00477 void zend_do_declare_class_constant(znode *var_name, const znode *value TSRMLS_DC);
00478 
00479 void zend_do_fetch_property(znode *result, znode *object, const znode *property TSRMLS_DC);
00480 
00481 void zend_do_halt_compiler_register(TSRMLS_D);
00482 
00483 void zend_do_push_object(const znode *object TSRMLS_DC);
00484 void zend_do_pop_object(znode *object TSRMLS_DC);
00485 
00486 
00487 void zend_do_begin_new_object(znode *new_token, znode *class_type TSRMLS_DC);
00488 void zend_do_end_new_object(znode *result, const znode *new_token, const znode *argument_list TSRMLS_DC);
00489 
00490 void zend_do_fetch_constant(znode *result, znode *constant_container, znode *constant_name, int mode, zend_bool check_namespace TSRMLS_DC);
00491 
00492 void zend_do_shell_exec(znode *result, const znode *cmd TSRMLS_DC);
00493 
00494 void zend_do_init_array(znode *result, const znode *expr, const znode *offset, zend_bool is_ref TSRMLS_DC);
00495 void zend_do_add_array_element(znode *result, const znode *expr, const znode *offset, zend_bool is_ref TSRMLS_DC);
00496 void zend_do_add_static_array_element(znode *result, znode *offset, const znode *expr);
00497 void zend_do_list_init(TSRMLS_D);
00498 void zend_do_list_end(znode *result, znode *expr TSRMLS_DC);
00499 void zend_do_add_list_element(const znode *element TSRMLS_DC);
00500 void zend_do_new_list_begin(TSRMLS_D);
00501 void zend_do_new_list_end(TSRMLS_D);
00502 
00503 void zend_do_cast(znode *result, const znode *expr, int type TSRMLS_DC);
00504 void zend_do_include_or_eval(int type, znode *result, const znode *op1 TSRMLS_DC);
00505 
00506 void zend_do_unset(const znode *variable TSRMLS_DC);
00507 void zend_do_isset_or_isempty(int type, znode *result, znode *variable TSRMLS_DC);
00508 
00509 void zend_do_instanceof(znode *result, const znode *expr, const znode *class_znode, int type TSRMLS_DC);
00510 
00511 void zend_do_foreach_begin(znode *foreach_token, znode *open_brackets_token, znode *array, znode *as_token, int variable TSRMLS_DC);
00512 void zend_do_foreach_cont(znode *foreach_token, const znode *open_brackets_token, const znode *as_token, znode *value, znode *key TSRMLS_DC);
00513 void zend_do_foreach_end(const znode *foreach_token, const znode *as_token TSRMLS_DC);
00514 
00515 void zend_do_declare_begin(TSRMLS_D);
00516 void zend_do_declare_stmt(znode *var, znode *val TSRMLS_DC);
00517 void zend_do_declare_end(const znode *declare_token TSRMLS_DC);
00518 
00519 void zend_do_exit(znode *result, const znode *message TSRMLS_DC);
00520 
00521 void zend_do_begin_silence(znode *strudel_token TSRMLS_DC);
00522 void zend_do_end_silence(const znode *strudel_token TSRMLS_DC);
00523 
00524 void zend_do_jmp_set(const znode *value, znode *jmp_token, znode *colon_token TSRMLS_DC);
00525 void zend_do_jmp_set_else(znode *result, const znode *false_value, const znode *jmp_token, const znode *colon_token TSRMLS_DC);
00526 
00527 void zend_do_begin_qm_op(const znode *cond, znode *qm_token TSRMLS_DC);
00528 void zend_do_qm_true(const znode *true_value, znode *qm_token, znode *colon_token TSRMLS_DC);
00529 void zend_do_qm_false(znode *result, const znode *false_value, const znode *qm_token, const znode *colon_token TSRMLS_DC);
00530 
00531 void zend_do_extended_info(TSRMLS_D);
00532 void zend_do_extended_fcall_begin(TSRMLS_D);
00533 void zend_do_extended_fcall_end(TSRMLS_D);
00534 
00535 void zend_do_ticks(TSRMLS_D);
00536 
00537 void zend_do_abstract_method(const znode *function_name, znode *modifiers, const znode *body TSRMLS_DC);
00538 
00539 void zend_do_declare_constant(znode *name, znode *value TSRMLS_DC);
00540 void zend_do_build_namespace_name(znode *result, znode *prefix, znode *name TSRMLS_DC);
00541 void zend_do_begin_namespace(const znode *name, zend_bool with_brackets TSRMLS_DC);
00542 void zend_do_end_namespace(TSRMLS_D);
00543 void zend_verify_namespace(TSRMLS_D);
00544 void zend_do_use(znode *name, znode *new_name, int is_global TSRMLS_DC);
00545 void zend_do_end_compilation(TSRMLS_D);
00546 
00547 void zend_do_label(znode *label TSRMLS_DC);
00548 void zend_do_goto(const znode *label TSRMLS_DC);
00549 void zend_resolve_goto_label(zend_op_array *op_array, zend_op *opline, int pass2 TSRMLS_DC);
00550 void zend_release_labels(TSRMLS_D);
00551 
00552 ZEND_API void function_add_ref(zend_function *function);
00553 
00554 #define INITIAL_OP_ARRAY_SIZE 64
00555 
00556 
00557 /* helper functions in zend_language_scanner.l */
00558 ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type TSRMLS_DC);
00559 ZEND_API zend_op_array *compile_string(zval *source_string, char *filename TSRMLS_DC);
00560 ZEND_API zend_op_array *compile_filename(int type, zval *filename TSRMLS_DC);
00561 ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval **retval, int file_count, ...);
00562 ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC);
00563 ZEND_API void init_op_array(zend_op_array *op_array, zend_uchar type, int initial_ops_size TSRMLS_DC);
00564 ZEND_API void destroy_op_array(zend_op_array *op_array TSRMLS_DC);
00565 ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle TSRMLS_DC);
00566 ZEND_API int zend_cleanup_class_data(zend_class_entry **pce TSRMLS_DC);
00567 ZEND_API int zend_cleanup_function_data(zend_function *function TSRMLS_DC);
00568 ZEND_API int zend_cleanup_function_data_full(zend_function *function TSRMLS_DC);
00569 
00570 ZEND_API void destroy_zend_function(zend_function *function TSRMLS_DC);
00571 ZEND_API void zend_function_dtor(zend_function *function);
00572 ZEND_API void destroy_zend_class(zend_class_entry **pce);
00573 void zend_class_add_ref(zend_class_entry **ce);
00574 
00575 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);
00576 ZEND_API int zend_unmangle_property_name(char *mangled_property, int mangled_property_len, char **prop_name, char **class_name);
00577 
00578 #define ZEND_FUNCTION_DTOR (void (*)(void *)) zend_function_dtor
00579 #define ZEND_CLASS_DTOR (void (*)(void *)) destroy_zend_class
00580 
00581 zend_op *get_next_op(zend_op_array *op_array TSRMLS_DC);
00582 void init_op(zend_op *op TSRMLS_DC);
00583 int get_next_op_number(zend_op_array *op_array);
00584 int print_class(zend_class_entry *class_entry TSRMLS_DC);
00585 void print_op_array(zend_op_array *op_array, int optimizations);
00586 ZEND_API int pass_two(zend_op_array *op_array TSRMLS_DC);
00587 zend_brk_cont_element *get_next_brk_cont_element(zend_op_array *op_array);
00588 void zend_do_first_catch(znode *open_parentheses TSRMLS_DC);
00589 void zend_initialize_try_catch_element(const znode *try_token TSRMLS_DC);
00590 void zend_do_mark_last_catch(const znode *first_catch, const znode *last_additional_catch TSRMLS_DC);
00591 ZEND_API zend_bool zend_is_compiling(TSRMLS_D);
00592 ZEND_API char *zend_make_compiled_string_description(const char *name TSRMLS_DC);
00593 ZEND_API void zend_initialize_class_data(zend_class_entry *ce, zend_bool nullify_handlers TSRMLS_DC);
00594 int zend_get_class_fetch_type(const char *class_name, uint class_name_len);
00595 
00596 typedef zend_bool (*zend_auto_global_callback)(char *name, uint name_len TSRMLS_DC);
00597 typedef struct _zend_auto_global {
00598        char *name;
00599        uint name_len;
00600        zend_auto_global_callback auto_global_callback;
00601        zend_bool armed;
00602 } zend_auto_global;
00603 
00604 void zend_auto_global_dtor(zend_auto_global *auto_global);
00605 ZEND_API int zend_register_auto_global(const char *name, uint name_len, zend_auto_global_callback auto_global_callback TSRMLS_DC);
00606 ZEND_API zend_bool zend_is_auto_global(const char *name, uint name_len TSRMLS_DC);
00607 ZEND_API int zend_auto_global_disable_jit(const char *varname, zend_uint varname_length TSRMLS_DC);
00608 ZEND_API size_t zend_dirname(char *path, size_t len);
00609 
00610 int zendlex(znode *zendlval TSRMLS_DC);
00611 
00612 /* BEGIN: OPCODES */
00613 
00614 #include "zend_vm_opcodes.h"
00615 
00616 #define ZEND_OP_DATA                      137
00617 
00618 /* END: OPCODES */
00619 
00620 
00621 
00622 
00623 /* global/local fetches */
00624 #define ZEND_FETCH_GLOBAL                 0
00625 #define ZEND_FETCH_LOCAL                  1
00626 #define ZEND_FETCH_STATIC                 2
00627 #define ZEND_FETCH_STATIC_MEMBER   3
00628 #define ZEND_FETCH_GLOBAL_LOCK            4
00629 #define ZEND_FETCH_LEXICAL                5
00630 
00631 
00632 /* class fetches */
00633 #define ZEND_FETCH_CLASS_DEFAULT   0
00634 #define ZEND_FETCH_CLASS_SELF             1
00635 #define ZEND_FETCH_CLASS_PARENT           2
00636 #define ZEND_FETCH_CLASS_MAIN             3
00637 #define ZEND_FETCH_CLASS_GLOBAL           4
00638 #define ZEND_FETCH_CLASS_AUTO             5
00639 #define ZEND_FETCH_CLASS_INTERFACE 6
00640 #define ZEND_FETCH_CLASS_STATIC           7
00641 #define ZEND_FETCH_CLASS_MASK        0x0f
00642 #define ZEND_FETCH_CLASS_NO_AUTOLOAD 0x80
00643 #define ZEND_FETCH_CLASS_SILENT      0x0100
00644 
00645 /* variable parsing type (compile-time) */
00646 #define ZEND_PARSED_MEMBER                       (1<<0)
00647 #define ZEND_PARSED_METHOD_CALL                  (1<<1)
00648 #define ZEND_PARSED_STATIC_MEMBER         (1<<2)
00649 #define ZEND_PARSED_FUNCTION_CALL         (1<<3)
00650 #define ZEND_PARSED_VARIABLE                     (1<<4)
00651 #define ZEND_PARSED_REFERENCE_VARIABLE    (1<<5)
00652 #define ZEND_PARSED_NEW                                 (1<<6)
00653 
00654 
00655 /* unset types */
00656 #define ZEND_UNSET_REG 0
00657 
00658 /* var status for backpatching */
00659 #define BP_VAR_R                   0
00660 #define BP_VAR_W                   1
00661 #define BP_VAR_RW                  2
00662 #define BP_VAR_IS                  3
00663 #define BP_VAR_NA                  4      /* if not applicable */
00664 #define BP_VAR_FUNC_ARG            5
00665 #define BP_VAR_UNSET        6
00666 
00667 
00668 #define ZEND_INTERNAL_FUNCTION                          1
00669 #define ZEND_USER_FUNCTION                              2
00670 #define ZEND_OVERLOADED_FUNCTION                 3
00671 #define       ZEND_EVAL_CODE                                          4
00672 #define ZEND_OVERLOADED_FUNCTION_TEMPORARY       5
00673 
00674 #define ZEND_INTERNAL_CLASS         1
00675 #define ZEND_USER_CLASS             2
00676 
00677 #define ZEND_EVAL                         (1<<0)
00678 #define ZEND_INCLUDE               (1<<1)
00679 #define ZEND_INCLUDE_ONCE          (1<<2)
00680 #define ZEND_REQUIRE               (1<<3)
00681 #define ZEND_REQUIRE_ONCE          (1<<4)
00682 
00683 #define ZEND_ISSET                        (1<<0)
00684 #define ZEND_ISEMPTY               (1<<1)
00685 #define ZEND_ISSET_ISEMPTY_MASK    (ZEND_ISSET | ZEND_ISEMPTY)
00686 #define ZEND_QUICK_SET                    (1<<2)
00687 
00688 #define ZEND_CT      (1<<0)
00689 #define ZEND_RT (1<<1)
00690 
00691 #define ZEND_FETCH_STANDARD     0x00000000
00692 #define ZEND_FETCH_ADD_LOCK     0x08000000
00693 #define ZEND_FETCH_MAKE_REF     0x04000000
00694 
00695 #define ZEND_FE_FETCH_BYREF 1
00696 #define ZEND_FE_FETCH_WITH_KEY     2
00697 
00698 #define ZEND_FE_RESET_VARIABLE            1
00699 #define ZEND_FE_RESET_REFERENCE           2
00700 
00701 #define ZEND_MEMBER_FUNC_CALL      1<<0
00702 
00703 #define ZEND_ARG_SEND_BY_REF (1<<0)
00704 #define ZEND_ARG_COMPILE_TIME_BOUND (1<<1)
00705 #define ZEND_ARG_SEND_FUNCTION (1<<2)
00706 #define ZEND_ARG_SEND_SILENT   (1<<3)
00707 
00708 #define ZEND_SEND_BY_VAL     0
00709 #define ZEND_SEND_BY_REF     1
00710 #define ZEND_SEND_PREFER_REF 2
00711 
00712 #define ARG_SEND_TYPE(zf, arg_num)                                                                              \
00713        ((zf) ?                                                                     \
00714         ((((zend_function*)(zf))->common.arg_info &&                               \
00715           arg_num<=((zend_function*)(zf))->common.num_args) ?                      \
00716          ((zend_function *)(zf))->common.arg_info[arg_num-1].pass_by_reference :   \
00717          ((zend_function *)(zf))->common.pass_rest_by_reference) :                 \
00718         ZEND_SEND_BY_VAL)   
00719 
00720 #define ARG_MUST_BE_SENT_BY_REF(zf, arg_num) \
00721        (ARG_SEND_TYPE(zf, arg_num) == ZEND_SEND_BY_REF)
00722 
00723 #define ARG_SHOULD_BE_SENT_BY_REF(zf, arg_num) \
00724        (ARG_SEND_TYPE(zf, arg_num) & (ZEND_SEND_BY_REF|ZEND_SEND_PREFER_REF))
00725 
00726 #define ARG_MAY_BE_SENT_BY_REF(zf, arg_num) \
00727        (ARG_SEND_TYPE(zf, arg_num) == ZEND_SEND_PREFER_REF)
00728 
00729 #define ZEND_RETURN_VAL 0
00730 #define ZEND_RETURN_REF 1
00731 
00732 
00733 #define ZEND_RETURNS_FUNCTION 1<<0
00734 #define ZEND_RETURNS_NEW      1<<1
00735 
00736 END_EXTERN_C()
00737 
00738 #define ZEND_CLONE_FUNC_NAME              "__clone"
00739 #define ZEND_CONSTRUCTOR_FUNC_NAME "__construct"
00740 #define ZEND_DESTRUCTOR_FUNC_NAME  "__destruct"
00741 #define ZEND_GET_FUNC_NAME          "__get"
00742 #define ZEND_SET_FUNC_NAME          "__set"
00743 #define ZEND_UNSET_FUNC_NAME        "__unset"
00744 #define ZEND_ISSET_FUNC_NAME        "__isset"
00745 #define ZEND_CALL_FUNC_NAME         "__call"
00746 #define ZEND_CALLSTATIC_FUNC_NAME   "__callstatic"
00747 #define ZEND_TOSTRING_FUNC_NAME     "__tostring"
00748 #define ZEND_AUTOLOAD_FUNC_NAME     "__autoload"
00749 
00750 /* The following constants may be combined in CG(compiler_options)
00751  * to change the default compiler behavior */
00752 
00753 /* generate extended debug information */
00754 #define ZEND_COMPILE_EXTENDED_INFO                      (1<<0)
00755 
00756 /* call op_array handler of extendions */
00757 #define ZEND_COMPILE_HANDLE_OP_ARRAY            (1<<1)
00758 
00759 /* generate ZEND_DO_FCALL_BY_NAME for internal functions instead of ZEND_DO_FCALL */
00760 #define ZEND_COMPILE_IGNORE_INTERNAL_FUNCTIONS   (1<<2)
00761 
00762 /* don't perform early binding for classes inherited form internal ones;
00763  * in namespaces assume that internal class that doesn't exist at compile-time
00764  * may apper in run-time */
00765 #define ZEND_COMPILE_IGNORE_INTERNAL_CLASSES     (1<<3)
00766 
00767 /* generate ZEND_DECLARE_INHERITED_CLASS_DELAYED opcode to delay early binding */
00768 #define ZEND_COMPILE_DELAYED_BINDING                    (1<<4)
00769 
00770 /* disable constant substitution at compile-time */
00771 #define ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION    (1<<5)
00772 
00773 /* The default value for CG(compiler_options) */
00774 #define ZEND_COMPILE_DEFAULT                                   ZEND_COMPILE_HANDLE_OP_ARRAY
00775 
00776 /* The default value for CG(compiler_options) during eval() */
00777 #define ZEND_COMPILE_DEFAULT_FOR_EVAL                   0
00778 
00779 #endif /* ZEND_COMPILE_H */
00780 
00781 /*
00782  * Local variables:
00783  * tab-width: 4
00784  * c-basic-offset: 4
00785  * indent-tabs-mode: t
00786  * End:
00787  */