zend_compile.h 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072
  1. /*
  2. +----------------------------------------------------------------------+
  3. | Zend Engine |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1998-2018 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@php.net> |
  16. | Zeev Suraski <zeev@php.net> |
  17. +----------------------------------------------------------------------+
  18. */
  19. #ifndef ZEND_COMPILE_H
  20. #define ZEND_COMPILE_H
  21. #include "zend.h"
  22. #include "zend_ast.h"
  23. #ifdef HAVE_STDARG_H
  24. # include <stdarg.h>
  25. #endif
  26. #include "zend_llist.h"
  27. #define SET_UNUSED(op) op ## _type = IS_UNUSED
  28. #define MAKE_NOP(opline) do { \
  29. (opline)->op1.num = 0; \
  30. (opline)->op2.num = 0; \
  31. (opline)->result.num = 0; \
  32. (opline)->opcode = ZEND_NOP; \
  33. (opline)->op1_type = IS_UNUSED; \
  34. (opline)->op2_type = IS_UNUSED; \
  35. (opline)->result_type = IS_UNUSED; \
  36. } while (0)
  37. #define RESET_DOC_COMMENT() do { \
  38. if (CG(doc_comment)) { \
  39. zend_string_release_ex(CG(doc_comment), 0); \
  40. CG(doc_comment) = NULL; \
  41. } \
  42. } while (0)
  43. typedef struct _zend_op_array zend_op_array;
  44. typedef struct _zend_op zend_op;
  45. /* On 64-bit systems less optimal, but more compact VM code leads to better
  46. * performance. So on 32-bit systems we use absolute addresses for jump
  47. * targets and constants, but on 64-bit systems realtive 32-bit offsets */
  48. #if SIZEOF_SIZE_T == 4
  49. # define ZEND_USE_ABS_JMP_ADDR 1
  50. # define ZEND_USE_ABS_CONST_ADDR 1
  51. # define ZEND_EX_USE_RUN_TIME_CACHE 1
  52. #else
  53. # define ZEND_USE_ABS_JMP_ADDR 0
  54. # define ZEND_USE_ABS_CONST_ADDR 0
  55. # define ZEND_EX_USE_RUN_TIME_CACHE 1
  56. #endif
  57. typedef union _znode_op {
  58. uint32_t constant;
  59. uint32_t var;
  60. uint32_t num;
  61. uint32_t opline_num; /* Needs to be signed */
  62. #if ZEND_USE_ABS_JMP_ADDR
  63. zend_op *jmp_addr;
  64. #else
  65. uint32_t jmp_offset;
  66. #endif
  67. #if ZEND_USE_ABS_CONST_ADDR
  68. zval *zv;
  69. #endif
  70. } znode_op;
  71. typedef struct _znode { /* used only during compilation */
  72. zend_uchar op_type;
  73. zend_uchar flag;
  74. union {
  75. znode_op op;
  76. zval constant; /* replaced by literal/zv */
  77. } u;
  78. } znode;
  79. /* Temporarily defined here, to avoid header ordering issues */
  80. typedef struct _zend_ast_znode {
  81. zend_ast_kind kind;
  82. zend_ast_attr attr;
  83. uint32_t lineno;
  84. znode node;
  85. } zend_ast_znode;
  86. ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_znode(znode *node);
  87. static zend_always_inline znode *zend_ast_get_znode(zend_ast *ast) {
  88. return &((zend_ast_znode *) ast)->node;
  89. }
  90. typedef struct _zend_declarables {
  91. zend_long ticks;
  92. } zend_declarables;
  93. /* Compilation context that is different for each file, but shared between op arrays. */
  94. typedef struct _zend_file_context {
  95. zend_declarables declarables;
  96. znode implementing_class;
  97. zend_string *current_namespace;
  98. zend_bool in_namespace;
  99. zend_bool has_bracketed_namespaces;
  100. HashTable *imports;
  101. HashTable *imports_function;
  102. HashTable *imports_const;
  103. HashTable seen_symbols;
  104. } zend_file_context;
  105. typedef union _zend_parser_stack_elem {
  106. zend_ast *ast;
  107. zend_string *str;
  108. zend_ulong num;
  109. } zend_parser_stack_elem;
  110. void zend_compile_top_stmt(zend_ast *ast);
  111. void zend_compile_stmt(zend_ast *ast);
  112. void zend_compile_expr(znode *node, zend_ast *ast);
  113. void zend_compile_var(znode *node, zend_ast *ast, uint32_t type);
  114. void zend_eval_const_expr(zend_ast **ast_ptr);
  115. void zend_const_expr_to_zval(zval *result, zend_ast *ast);
  116. typedef int (*user_opcode_handler_t) (zend_execute_data *execute_data);
  117. struct _zend_op {
  118. const void *handler;
  119. znode_op op1;
  120. znode_op op2;
  121. znode_op result;
  122. uint32_t extended_value;
  123. uint32_t lineno;
  124. zend_uchar opcode;
  125. zend_uchar op1_type;
  126. zend_uchar op2_type;
  127. zend_uchar result_type;
  128. };
  129. typedef struct _zend_brk_cont_element {
  130. int start;
  131. int cont;
  132. int brk;
  133. int parent;
  134. zend_bool is_switch;
  135. } zend_brk_cont_element;
  136. typedef struct _zend_label {
  137. int brk_cont;
  138. uint32_t opline_num;
  139. } zend_label;
  140. typedef struct _zend_try_catch_element {
  141. uint32_t try_op;
  142. uint32_t catch_op; /* ketchup! */
  143. uint32_t finally_op;
  144. uint32_t finally_end;
  145. } zend_try_catch_element;
  146. #define ZEND_LIVE_TMPVAR 0
  147. #define ZEND_LIVE_LOOP 1
  148. #define ZEND_LIVE_SILENCE 2
  149. #define ZEND_LIVE_ROPE 3
  150. #define ZEND_LIVE_MASK 3
  151. typedef struct _zend_live_range {
  152. uint32_t var; /* low bits are used for variable type (ZEND_LIVE_* macros) */
  153. uint32_t start;
  154. uint32_t end;
  155. } zend_live_range;
  156. /* Compilation context that is different for each op array. */
  157. typedef struct _zend_oparray_context {
  158. uint32_t opcodes_size;
  159. int vars_size;
  160. int literals_size;
  161. int backpatch_count;
  162. uint32_t fast_call_var;
  163. uint32_t try_catch_offset;
  164. int current_brk_cont;
  165. int last_brk_cont;
  166. zend_brk_cont_element *brk_cont_array;
  167. HashTable *labels;
  168. } zend_oparray_context;
  169. /* Class, property and method flags class|meth.|prop.|const*/
  170. /* | | | */
  171. /* Common flags | | | */
  172. /* ============ | | | */
  173. /* | | | */
  174. /* Staic method or property | | | */
  175. #define ZEND_ACC_STATIC (1 << 0) /* | X | X | */
  176. /* | | | */
  177. /* Final class or method | | | */
  178. #define ZEND_ACC_FINAL (1 << 2) /* X | X | | */
  179. /* | | | */
  180. /* Visibility flags (public < protected < private) | | | */
  181. #define ZEND_ACC_PUBLIC (1 << 8) /* | X | X | X */
  182. #define ZEND_ACC_PROTECTED (1 << 9) /* | X | X | X */
  183. #define ZEND_ACC_PRIVATE (1 << 10) /* | X | X | X */
  184. /* | | | */
  185. /* TODO: explain the name ??? | | | */
  186. #define ZEND_ACC_CHANGED (1 << 11) /* | X | X | */
  187. /* | | | */
  188. /* TODO: used only by ext/reflection ??? | | | */
  189. #define ZEND_ACC_IMPLICIT_PUBLIC (1 << 12) /* | ? | ? | ? */
  190. /* | | | */
  191. /* Shadow of parent's private method/property | | | */
  192. #define ZEND_ACC_SHADOW (1 << 17) /* | ? | X | */
  193. /* | | | */
  194. /* Class Flags (unused: 0, 1, 3, 11-18, 21, 25...) | | | */
  195. /* =========== | | | */
  196. /* | | | */
  197. /* class is abstarct, since it is set by any | | | */
  198. /* abstract method | | | */
  199. #define ZEND_ACC_IMPLICIT_ABSTRACT_CLASS (1 << 4) /* X | | | */
  200. /* | | | */
  201. /* Class is explicitly defined as abstract by using | | | */
  202. /* the keyword. | | | */
  203. #define ZEND_ACC_EXPLICIT_ABSTRACT_CLASS (1 << 5) /* X | | | */
  204. /* | | | */
  205. /* Special class types | | | */
  206. #define ZEND_ACC_INTERFACE (1 << 6) /* X | | | */
  207. #define ZEND_ACC_TRAIT (1 << 7) /* X | | | */
  208. #define ZEND_ACC_ANON_CLASS (1 << 8) /* X | | | */
  209. /* | | | */
  210. /* Bound anonymous class | | | */
  211. #define ZEND_ACC_ANON_BOUND (1 << 9) /* X | | | */
  212. /* | | | */
  213. /* Class extends another class | | | */
  214. #define ZEND_ACC_INHERITED (1 << 10) /* X | | | */
  215. /* | | | */
  216. /* Class implements interface(s) | | | */
  217. #define ZEND_ACC_IMPLEMENT_INTERFACES (1 << 19) /* X | | | */
  218. /* | | | */
  219. /* Class constants updated | | | */
  220. #define ZEND_ACC_CONSTANTS_UPDATED (1 << 20) /* X | | | */
  221. /* | | | */
  222. /* Class uses trait(s) | | | */
  223. #define ZEND_ACC_IMPLEMENT_TRAITS (1 << 22) /* X | | | */
  224. /* | | | */
  225. /* User class has methods with static variables | | | */
  226. #define ZEND_HAS_STATIC_IN_METHODS (1 << 23) /* X | | | */
  227. /* | | | */
  228. /* Class has magic methods __get/__set/__unset/ | | | */
  229. /* __isset that use guards | | | */
  230. #define ZEND_ACC_USE_GUARDS (1 << 24) /* X | | | */
  231. /* | | | */
  232. /* Function Flags (unused: 4, 5, 17?) | | | */
  233. /* ============== | | | */
  234. /* | | | */
  235. /* Abstarct method | | | */
  236. #define ZEND_ACC_ABSTRACT (1 << 1) /* | X | | */
  237. /* | | | */
  238. /* TODO: used only during inheritance ??? | | | */
  239. #define ZEND_ACC_IMPLEMENTED_ABSTRACT (1 << 3) /* | X | | */
  240. /* | | | */
  241. #define ZEND_ACC_FAKE_CLOSURE (1 << 6) /* | X | | */
  242. /* | | | */
  243. /* method flag used by Closure::__invoke() | | | */
  244. #define ZEND_ACC_USER_ARG_INFO (1 << 7) /* | X | | */
  245. /* | | | */
  246. /* method flags (special method detection) | | | */
  247. #define ZEND_ACC_CTOR (1 << 13) /* | X | | */
  248. #define ZEND_ACC_DTOR (1 << 14) /* | X | | */
  249. /* | | | */
  250. /* "main" op_array with | | | */
  251. /* ZEND_DECLARE_INHERITED_CLASS_DELAYED opcodes | | | */
  252. #define ZEND_ACC_EARLY_BINDING (1 << 15) /* | X | | */
  253. /* | | | */
  254. /* method flag (bc only), any method that has this | | | */
  255. /* flag can be used statically and non statically. | | | */
  256. #define ZEND_ACC_ALLOW_STATIC (1 << 16) /* | X | | */
  257. /* | | | */
  258. /* deprecation flag | | | */
  259. #define ZEND_ACC_DEPRECATED (1 << 18) /* | X | | */
  260. /* | | | */
  261. #define ZEND_ACC_NO_RT_ARENA (1 << 19) /* | X | | */
  262. /* | | | */
  263. #define ZEND_ACC_CLOSURE (1 << 20) /* | X | | */
  264. /* | | | */
  265. /* call through user function trampoline. e.g. | | | */
  266. /* __call, __callstatic | | | */
  267. #define ZEND_ACC_CALL_VIA_TRAMPOLINE (1 << 21) /* | X | | */
  268. /* | | | */
  269. /* disable inline caching | | | */
  270. #define ZEND_ACC_NEVER_CACHE (1 << 22) /* | X | | */
  271. /* | | | */
  272. #define ZEND_ACC_GENERATOR (1 << 23) /* | X | | */
  273. /* | | | */
  274. /* Function with varable number of arguments | | | */
  275. #define ZEND_ACC_VARIADIC (1 << 24) /* | X | | */
  276. /* | | | */
  277. /* Immutable op_array (lazy loading) | | | */
  278. #define ZEND_ACC_IMMUTABLE (1 << 25) /* | X | | */
  279. /* | | | */
  280. /* Function returning by reference | | | */
  281. #define ZEND_ACC_RETURN_REFERENCE (1 << 26) /* | X | | */
  282. /* | | | */
  283. #define ZEND_ACC_DONE_PASS_TWO (1 << 27) /* | X | | */
  284. /* | | | */
  285. /* Function has typed arguments | | | */
  286. #define ZEND_ACC_HAS_TYPE_HINTS (1 << 28) /* | X | | */
  287. /* | | | */
  288. /* op_array has finally blocks (user only) | | | */
  289. #define ZEND_ACC_HAS_FINALLY_BLOCK (1 << 29) /* | X | | */
  290. /* | | | */
  291. /* internal function is allocated at arena (int only) | | | */
  292. #define ZEND_ACC_ARENA_ALLOCATED (1 << 29) /* | X | | */
  293. /* | | | */
  294. /* Function has a return type | | | */
  295. #define ZEND_ACC_HAS_RETURN_TYPE (1 << 30) /* | X | | */
  296. /* | | | */
  297. /* op_array uses strict mode types | | | */
  298. #define ZEND_ACC_STRICT_TYPES (1 << 31) /* | X | | */
  299. #define ZEND_ACC_PPP_MASK (ZEND_ACC_PUBLIC | ZEND_ACC_PROTECTED | ZEND_ACC_PRIVATE)
  300. /* call through internal function handler. e.g. Closure::invoke() */
  301. #define ZEND_ACC_CALL_VIA_HANDLER ZEND_ACC_CALL_VIA_TRAMPOLINE
  302. char *zend_visibility_string(uint32_t fn_flags);
  303. typedef struct _zend_property_info {
  304. uint32_t offset; /* property offset for object properties or
  305. property index for static properties */
  306. uint32_t flags;
  307. zend_string *name;
  308. zend_string *doc_comment;
  309. zend_class_entry *ce;
  310. } zend_property_info;
  311. #define OBJ_PROP(obj, offset) \
  312. ((zval*)((char*)(obj) + offset))
  313. #define OBJ_PROP_NUM(obj, num) \
  314. (&(obj)->properties_table[(num)])
  315. #define OBJ_PROP_TO_OFFSET(num) \
  316. ((uint32_t)(zend_uintptr_t)OBJ_PROP_NUM(((zend_object*)NULL), num))
  317. #define OBJ_PROP_TO_NUM(offset) \
  318. ((offset - OBJ_PROP_TO_OFFSET(0)) / sizeof(zval))
  319. typedef struct _zend_class_constant {
  320. zval value; /* access flags are stored in reserved: zval.u2.access_flags */
  321. zend_string *doc_comment;
  322. zend_class_entry *ce;
  323. } zend_class_constant;
  324. /* arg_info for internal functions */
  325. typedef struct _zend_internal_arg_info {
  326. const char *name;
  327. zend_type type;
  328. zend_uchar pass_by_reference;
  329. zend_bool is_variadic;
  330. } zend_internal_arg_info;
  331. /* arg_info for user functions */
  332. typedef struct _zend_arg_info {
  333. zend_string *name;
  334. zend_type type;
  335. zend_uchar pass_by_reference;
  336. zend_bool is_variadic;
  337. } zend_arg_info;
  338. /* the following structure repeats the layout of zend_internal_arg_info,
  339. * but its fields have different meaning. It's used as the first element of
  340. * arg_info array to define properties of internal functions.
  341. * It's also used for the return type.
  342. */
  343. typedef struct _zend_internal_function_info {
  344. zend_uintptr_t required_num_args;
  345. zend_type type;
  346. zend_bool return_reference;
  347. zend_bool _is_variadic;
  348. } zend_internal_function_info;
  349. struct _zend_op_array {
  350. /* Common elements */
  351. zend_uchar type;
  352. zend_uchar arg_flags[3]; /* bitset of arg_info.pass_by_reference */
  353. uint32_t fn_flags;
  354. zend_string *function_name;
  355. zend_class_entry *scope;
  356. zend_function *prototype;
  357. uint32_t num_args;
  358. uint32_t required_num_args;
  359. zend_arg_info *arg_info;
  360. /* END of common elements */
  361. int cache_size; /* number of run_time_cache_slots * sizeof(void*) */
  362. int last_var; /* number of CV variables */
  363. uint32_t T; /* number of temporary variables */
  364. uint32_t last; /* number of opcodes */
  365. zend_op *opcodes;
  366. void **run_time_cache;
  367. HashTable *static_variables;
  368. zend_string **vars; /* names of CV variables */
  369. uint32_t *refcount;
  370. int last_live_range;
  371. int last_try_catch;
  372. zend_live_range *live_range;
  373. zend_try_catch_element *try_catch_array;
  374. zend_string *filename;
  375. uint32_t line_start;
  376. uint32_t line_end;
  377. zend_string *doc_comment;
  378. int last_literal;
  379. zval *literals;
  380. void *reserved[ZEND_MAX_RESERVED_RESOURCES];
  381. };
  382. #define ZEND_RETURN_VALUE 0
  383. #define ZEND_RETURN_REFERENCE 1
  384. /* zend_internal_function_handler */
  385. typedef void (ZEND_FASTCALL *zif_handler)(INTERNAL_FUNCTION_PARAMETERS);
  386. typedef struct _zend_internal_function {
  387. /* Common elements */
  388. zend_uchar type;
  389. zend_uchar arg_flags[3]; /* bitset of arg_info.pass_by_reference */
  390. uint32_t fn_flags;
  391. zend_string* function_name;
  392. zend_class_entry *scope;
  393. zend_function *prototype;
  394. uint32_t num_args;
  395. uint32_t required_num_args;
  396. zend_internal_arg_info *arg_info;
  397. /* END of common elements */
  398. zif_handler handler;
  399. struct _zend_module_entry *module;
  400. void *reserved[ZEND_MAX_RESERVED_RESOURCES];
  401. } zend_internal_function;
  402. #define ZEND_FN_SCOPE_NAME(function) ((function) && (function)->common.scope ? ZSTR_VAL((function)->common.scope->name) : "")
  403. union _zend_function {
  404. zend_uchar type; /* MUST be the first element of this struct! */
  405. uint32_t quick_arg_flags;
  406. struct {
  407. zend_uchar type; /* never used */
  408. zend_uchar arg_flags[3]; /* bitset of arg_info.pass_by_reference */
  409. uint32_t fn_flags;
  410. zend_string *function_name;
  411. zend_class_entry *scope;
  412. union _zend_function *prototype;
  413. uint32_t num_args;
  414. uint32_t required_num_args;
  415. zend_arg_info *arg_info;
  416. } common;
  417. zend_op_array op_array;
  418. zend_internal_function internal_function;
  419. };
  420. typedef enum _zend_call_kind {
  421. ZEND_CALL_NESTED_FUNCTION, /* stackless VM call to function */
  422. ZEND_CALL_NESTED_CODE, /* stackless VM call to include/require/eval */
  423. ZEND_CALL_TOP_FUNCTION, /* direct VM call to function from external C code */
  424. ZEND_CALL_TOP_CODE /* direct VM call to "main" code from external C code */
  425. } zend_call_kind;
  426. struct _zend_execute_data {
  427. const zend_op *opline; /* executed opline */
  428. zend_execute_data *call; /* current call */
  429. zval *return_value;
  430. zend_function *func; /* executed function */
  431. zval This; /* this + call_info + num_args */
  432. zend_execute_data *prev_execute_data;
  433. zend_array *symbol_table;
  434. #if ZEND_EX_USE_RUN_TIME_CACHE
  435. void **run_time_cache; /* cache op_array->run_time_cache */
  436. #endif
  437. };
  438. #define ZEND_CALL_FUNCTION (0 << 0)
  439. #define ZEND_CALL_CODE (1 << 0)
  440. #define ZEND_CALL_NESTED (0 << 1)
  441. #define ZEND_CALL_TOP (1 << 1)
  442. #define ZEND_CALL_FREE_EXTRA_ARGS (1 << 2)
  443. #define ZEND_CALL_CTOR (1 << 3)
  444. #define ZEND_CALL_HAS_SYMBOL_TABLE (1 << 4)
  445. #define ZEND_CALL_CLOSURE (1 << 5)
  446. #define ZEND_CALL_RELEASE_THIS (1 << 6)
  447. #define ZEND_CALL_ALLOCATED (1 << 7)
  448. #define ZEND_CALL_GENERATOR (1 << 8)
  449. #define ZEND_CALL_DYNAMIC (1 << 9)
  450. #define ZEND_CALL_FAKE_CLOSURE (1 << 10)
  451. #define ZEND_CALL_SEND_ARG_BY_REF (1 << 11)
  452. #define ZEND_CALL_INFO_SHIFT 16
  453. #define ZEND_CALL_INFO(call) \
  454. (Z_TYPE_INFO((call)->This) >> ZEND_CALL_INFO_SHIFT)
  455. #define ZEND_CALL_KIND_EX(call_info) \
  456. (call_info & (ZEND_CALL_CODE | ZEND_CALL_TOP))
  457. #define ZEND_CALL_KIND(call) \
  458. ZEND_CALL_KIND_EX(ZEND_CALL_INFO(call))
  459. #define ZEND_SET_CALL_INFO(call, object, info) do { \
  460. Z_TYPE_INFO((call)->This) = ((object) ? IS_OBJECT_EX : IS_UNDEF) | ((info) << ZEND_CALL_INFO_SHIFT); \
  461. } while (0)
  462. #define ZEND_ADD_CALL_FLAG_EX(call_info, flag) do { \
  463. call_info |= ((flag) << ZEND_CALL_INFO_SHIFT); \
  464. } while (0)
  465. #define ZEND_DEL_CALL_FLAG_EX(call_info, flag) do { \
  466. call_info &= ~((flag) << ZEND_CALL_INFO_SHIFT); \
  467. } while (0)
  468. #define ZEND_ADD_CALL_FLAG(call, flag) do { \
  469. ZEND_ADD_CALL_FLAG_EX(Z_TYPE_INFO((call)->This), flag); \
  470. } while (0)
  471. #define ZEND_DEL_CALL_FLAG(call, flag) do { \
  472. ZEND_DEL_CALL_FLAG_EX(Z_TYPE_INFO((call)->This), flag); \
  473. } while (0)
  474. #define ZEND_CALL_NUM_ARGS(call) \
  475. (call)->This.u2.num_args
  476. #define ZEND_CALL_FRAME_SLOT \
  477. ((int)((ZEND_MM_ALIGNED_SIZE(sizeof(zend_execute_data)) + ZEND_MM_ALIGNED_SIZE(sizeof(zval)) - 1) / ZEND_MM_ALIGNED_SIZE(sizeof(zval))))
  478. #define ZEND_CALL_VAR(call, n) \
  479. ((zval*)(((char*)(call)) + ((int)(n))))
  480. #define ZEND_CALL_VAR_NUM(call, n) \
  481. (((zval*)(call)) + (ZEND_CALL_FRAME_SLOT + ((int)(n))))
  482. #define ZEND_CALL_ARG(call, n) \
  483. ZEND_CALL_VAR_NUM(call, ((int)(n)) - 1)
  484. #define EX(element) ((execute_data)->element)
  485. #define EX_CALL_INFO() ZEND_CALL_INFO(execute_data)
  486. #define EX_CALL_KIND() ZEND_CALL_KIND(execute_data)
  487. #define EX_NUM_ARGS() ZEND_CALL_NUM_ARGS(execute_data)
  488. #define ZEND_CALL_USES_STRICT_TYPES(call) \
  489. (((call)->func->common.fn_flags & ZEND_ACC_STRICT_TYPES) != 0)
  490. #define EX_USES_STRICT_TYPES() \
  491. ZEND_CALL_USES_STRICT_TYPES(execute_data)
  492. #define ZEND_ARG_USES_STRICT_TYPES() \
  493. (EG(current_execute_data)->prev_execute_data && \
  494. EG(current_execute_data)->prev_execute_data->func && \
  495. ZEND_CALL_USES_STRICT_TYPES(EG(current_execute_data)->prev_execute_data))
  496. #define ZEND_RET_USES_STRICT_TYPES() \
  497. ZEND_CALL_USES_STRICT_TYPES(EG(current_execute_data))
  498. #define EX_VAR(n) ZEND_CALL_VAR(execute_data, n)
  499. #define EX_VAR_NUM(n) ZEND_CALL_VAR_NUM(execute_data, n)
  500. #define EX_VAR_TO_NUM(n) ((uint32_t)(ZEND_CALL_VAR(NULL, n) - ZEND_CALL_VAR_NUM(NULL, 0)))
  501. #define ZEND_OPLINE_TO_OFFSET(opline, target) \
  502. ((char*)(target) - (char*)(opline))
  503. #define ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, opline_num) \
  504. ((char*)&(op_array)->opcodes[opline_num] - (char*)(opline))
  505. #define ZEND_OFFSET_TO_OPLINE(base, offset) \
  506. ((zend_op*)(((char*)(base)) + (int)offset))
  507. #define ZEND_OFFSET_TO_OPLINE_NUM(op_array, base, offset) \
  508. (ZEND_OFFSET_TO_OPLINE(base, offset) - op_array->opcodes)
  509. #if ZEND_USE_ABS_JMP_ADDR
  510. /* run-time jump target */
  511. # define OP_JMP_ADDR(opline, node) \
  512. (node).jmp_addr
  513. # define ZEND_SET_OP_JMP_ADDR(opline, node, val) do { \
  514. (node).jmp_addr = (val); \
  515. } while (0)
  516. /* convert jump target from compile-time to run-time */
  517. # define ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, node) do { \
  518. (node).jmp_addr = (op_array)->opcodes + (node).opline_num; \
  519. } while (0)
  520. /* convert jump target back from run-time to compile-time */
  521. # define ZEND_PASS_TWO_UNDO_JMP_TARGET(op_array, opline, node) do { \
  522. (node).opline_num = (node).jmp_addr - (op_array)->opcodes; \
  523. } while (0)
  524. #else
  525. /* run-time jump target */
  526. # define OP_JMP_ADDR(opline, node) \
  527. ZEND_OFFSET_TO_OPLINE(opline, (node).jmp_offset)
  528. # define ZEND_SET_OP_JMP_ADDR(opline, node, val) do { \
  529. (node).jmp_offset = ZEND_OPLINE_TO_OFFSET(opline, val); \
  530. } while (0)
  531. /* convert jump target from compile-time to run-time */
  532. # define ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, node) do { \
  533. (node).jmp_offset = ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, (node).opline_num); \
  534. } while (0)
  535. /* convert jump target back from run-time to compile-time */
  536. # define ZEND_PASS_TWO_UNDO_JMP_TARGET(op_array, opline, node) do { \
  537. (node).opline_num = ZEND_OFFSET_TO_OPLINE_NUM(op_array, opline, (node).jmp_offset); \
  538. } while (0)
  539. #endif
  540. /* constant-time constant */
  541. # define CT_CONSTANT_EX(op_array, num) \
  542. ((op_array)->literals + (num))
  543. # define CT_CONSTANT(node) \
  544. CT_CONSTANT_EX(CG(active_op_array), (node).constant)
  545. #if ZEND_USE_ABS_CONST_ADDR
  546. /* run-time constant */
  547. # define RT_CONSTANT(opline, node) \
  548. (node).zv
  549. /* convert constant from compile-time to run-time */
  550. # define ZEND_PASS_TWO_UPDATE_CONSTANT(op_array, opline, node) do { \
  551. (node).zv = CT_CONSTANT_EX(op_array, (node).constant); \
  552. } while (0)
  553. #else
  554. /* At run-time, constants are allocated together with op_array->opcodes
  555. * and addressed relatively to current opline.
  556. */
  557. /* run-time constant */
  558. # define RT_CONSTANT(opline, node) \
  559. ((zval*)(((char*)(opline)) + (int32_t)(node).constant))
  560. /* convert constant from compile-time to run-time */
  561. # define ZEND_PASS_TWO_UPDATE_CONSTANT(op_array, opline, node) do { \
  562. (node).constant = \
  563. (((char*)CT_CONSTANT_EX(op_array, (node).constant)) - \
  564. ((char*)opline)); \
  565. } while (0)
  566. #endif
  567. /* convert constant back from run-time to compile-time */
  568. #define ZEND_PASS_TWO_UNDO_CONSTANT(op_array, opline, node) do { \
  569. (node).constant = RT_CONSTANT(opline, node) - (op_array)->literals; \
  570. } while (0)
  571. #if ZEND_EX_USE_RUN_TIME_CACHE
  572. # define EX_RUN_TIME_CACHE() \
  573. EX(run_time_cache)
  574. # define EX_LOAD_RUN_TIME_CACHE(op_array) do { \
  575. EX(run_time_cache) = (op_array)->run_time_cache; \
  576. } while (0)
  577. #else
  578. # define EX_RUN_TIME_CACHE() \
  579. EX(func)->op_array.run_time_cache
  580. # define EX_LOAD_RUN_TIME_CACHE(op_array) do { \
  581. } while (0)
  582. #endif
  583. #define IS_UNUSED 0 /* Unused operand */
  584. #define IS_CONST (1<<0)
  585. #define IS_TMP_VAR (1<<1)
  586. #define IS_VAR (1<<2)
  587. #define IS_CV (1<<3) /* Compiled variable */
  588. #define ZEND_EXTRA_VALUE 1
  589. #include "zend_globals.h"
  590. BEGIN_EXTERN_C()
  591. void init_compiler(void);
  592. void shutdown_compiler(void);
  593. void zend_init_compiler_data_structures(void);
  594. void zend_oparray_context_begin(zend_oparray_context *prev_context);
  595. void zend_oparray_context_end(zend_oparray_context *prev_context);
  596. void zend_file_context_begin(zend_file_context *prev_context);
  597. void zend_file_context_end(zend_file_context *prev_context);
  598. extern ZEND_API zend_op_array *(*zend_compile_file)(zend_file_handle *file_handle, int type);
  599. extern ZEND_API zend_op_array *(*zend_compile_string)(zval *source_string, char *filename);
  600. ZEND_API int ZEND_FASTCALL lex_scan(zval *zendlval, zend_parser_stack_elem *elem);
  601. void startup_scanner(void);
  602. void shutdown_scanner(void);
  603. ZEND_API zend_string *zend_set_compiled_filename(zend_string *new_compiled_filename);
  604. ZEND_API void zend_restore_compiled_filename(zend_string *original_compiled_filename);
  605. ZEND_API zend_string *zend_get_compiled_filename(void);
  606. ZEND_API int zend_get_compiled_lineno(void);
  607. ZEND_API size_t zend_get_scanned_file_offset(void);
  608. ZEND_API zend_string *zend_get_compiled_variable_name(const zend_op_array *op_array, uint32_t var);
  609. #ifdef ZTS
  610. const char *zend_get_zendtext(void);
  611. int zend_get_zendleng(void);
  612. #endif
  613. typedef int (ZEND_FASTCALL *unary_op_type)(zval *, zval *);
  614. typedef int (ZEND_FASTCALL *binary_op_type)(zval *, zval *, zval *);
  615. ZEND_API unary_op_type get_unary_op(int opcode);
  616. ZEND_API binary_op_type get_binary_op(int opcode);
  617. void zend_stop_lexing(void);
  618. void zend_emit_final_return(int return_one);
  619. /* Used during AST construction */
  620. zend_ast *zend_ast_append_str(zend_ast *left, zend_ast *right);
  621. zend_ast *zend_negate_num_string(zend_ast *ast);
  622. uint32_t zend_add_class_modifier(uint32_t flags, uint32_t new_flag);
  623. uint32_t zend_add_member_modifier(uint32_t flags, uint32_t new_flag);
  624. zend_bool zend_handle_encoding_declaration(zend_ast *ast);
  625. /* parser-driven code generators */
  626. void zend_do_free(znode *op1);
  627. ZEND_API int do_bind_function(const zend_op_array *op_array, const zend_op *opline, HashTable *function_table, zend_bool compile_time);
  628. 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);
  629. 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);
  630. ZEND_API uint32_t zend_build_delayed_early_binding_list(const zend_op_array *op_array);
  631. ZEND_API void zend_do_delayed_early_binding(const zend_op_array *op_array, uint32_t first_early_binding_opline);
  632. void zend_do_extended_info(void);
  633. void zend_do_extended_fcall_begin(void);
  634. void zend_do_extended_fcall_end(void);
  635. void zend_verify_namespace(void);
  636. void zend_resolve_goto_label(zend_op_array *op_array, zend_op *opline);
  637. ZEND_API void function_add_ref(zend_function *function);
  638. #define INITIAL_OP_ARRAY_SIZE 64
  639. /* helper functions in zend_language_scanner.l */
  640. ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type);
  641. ZEND_API zend_op_array *compile_string(zval *source_string, char *filename);
  642. ZEND_API zend_op_array *compile_filename(int type, zval *filename);
  643. ZEND_API void zend_try_exception_handler();
  644. ZEND_API int zend_execute_scripts(int type, zval *retval, int file_count, ...);
  645. ZEND_API int open_file_for_scanning(zend_file_handle *file_handle);
  646. ZEND_API void init_op_array(zend_op_array *op_array, zend_uchar type, int initial_ops_size);
  647. ZEND_API void destroy_op_array(zend_op_array *op_array);
  648. ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle);
  649. ZEND_API void zend_cleanup_internal_class_data(zend_class_entry *ce);
  650. ZEND_API void zend_cleanup_internal_classes(void);
  651. ZEND_API void destroy_zend_function(zend_function *function);
  652. ZEND_API void zend_function_dtor(zval *zv);
  653. ZEND_API void destroy_zend_class(zval *zv);
  654. void zend_class_add_ref(zval *zv);
  655. ZEND_API zend_string *zend_mangle_property_name(const char *src1, size_t src1_length, const char *src2, size_t src2_length, int internal);
  656. #define zend_unmangle_property_name(mangled_property, class_name, prop_name) \
  657. zend_unmangle_property_name_ex(mangled_property, class_name, prop_name, NULL)
  658. ZEND_API int zend_unmangle_property_name_ex(const zend_string *name, const char **class_name, const char **prop_name, size_t *prop_len);
  659. #define ZEND_FUNCTION_DTOR zend_function_dtor
  660. #define ZEND_CLASS_DTOR destroy_zend_class
  661. ZEND_API int pass_two(zend_op_array *op_array);
  662. ZEND_API zend_bool zend_is_compiling(void);
  663. ZEND_API char *zend_make_compiled_string_description(const char *name);
  664. ZEND_API void zend_initialize_class_data(zend_class_entry *ce, zend_bool nullify_handlers);
  665. uint32_t zend_get_class_fetch_type(zend_string *name);
  666. ZEND_API zend_uchar zend_get_call_op(const zend_op *init_op, zend_function *fbc);
  667. ZEND_API int zend_is_smart_branch(zend_op *opline);
  668. static zend_always_inline uint32_t get_next_op_number(zend_op_array *op_array)
  669. {
  670. return op_array->last;
  671. }
  672. typedef zend_bool (*zend_auto_global_callback)(zend_string *name);
  673. typedef struct _zend_auto_global {
  674. zend_string *name;
  675. zend_auto_global_callback auto_global_callback;
  676. zend_bool jit;
  677. zend_bool armed;
  678. } zend_auto_global;
  679. ZEND_API int zend_register_auto_global(zend_string *name, zend_bool jit, zend_auto_global_callback auto_global_callback);
  680. ZEND_API void zend_activate_auto_globals(void);
  681. ZEND_API zend_bool zend_is_auto_global(zend_string *name);
  682. ZEND_API zend_bool zend_is_auto_global_str(char *name, size_t len);
  683. ZEND_API size_t zend_dirname(char *path, size_t len);
  684. ZEND_API void zend_set_function_arg_flags(zend_function *func);
  685. int ZEND_FASTCALL zendlex(zend_parser_stack_elem *elem);
  686. int zend_add_literal(zend_op_array *op_array, zval *zv);
  687. void zend_assert_valid_class_name(const zend_string *const_name);
  688. /* BEGIN: OPCODES */
  689. #include "zend_vm_opcodes.h"
  690. /* END: OPCODES */
  691. /* class fetches */
  692. #define ZEND_FETCH_CLASS_DEFAULT 0
  693. #define ZEND_FETCH_CLASS_SELF 1
  694. #define ZEND_FETCH_CLASS_PARENT 2
  695. #define ZEND_FETCH_CLASS_STATIC 3
  696. #define ZEND_FETCH_CLASS_AUTO 4
  697. #define ZEND_FETCH_CLASS_INTERFACE 5
  698. #define ZEND_FETCH_CLASS_TRAIT 6
  699. #define ZEND_FETCH_CLASS_MASK 0x0f
  700. #define ZEND_FETCH_CLASS_NO_AUTOLOAD 0x80
  701. #define ZEND_FETCH_CLASS_SILENT 0x0100
  702. #define ZEND_FETCH_CLASS_EXCEPTION 0x0200
  703. #define ZEND_PARAM_REF (1<<0)
  704. #define ZEND_PARAM_VARIADIC (1<<1)
  705. #define ZEND_NAME_FQ 0
  706. #define ZEND_NAME_NOT_FQ 1
  707. #define ZEND_NAME_RELATIVE 2
  708. #define ZEND_TYPE_NULLABLE (1<<8)
  709. #define ZEND_ARRAY_SYNTAX_LIST 1 /* list() */
  710. #define ZEND_ARRAY_SYNTAX_LONG 2 /* array() */
  711. #define ZEND_ARRAY_SYNTAX_SHORT 3 /* [] */
  712. /* var status for backpatching */
  713. #define BP_VAR_R 0
  714. #define BP_VAR_W 1
  715. #define BP_VAR_RW 2
  716. #define BP_VAR_IS 3
  717. #define BP_VAR_FUNC_ARG 4
  718. #define BP_VAR_UNSET 5
  719. #define ZEND_INTERNAL_FUNCTION 1
  720. #define ZEND_USER_FUNCTION 2
  721. #define ZEND_OVERLOADED_FUNCTION 3
  722. #define ZEND_EVAL_CODE 4
  723. #define ZEND_OVERLOADED_FUNCTION_TEMPORARY 5
  724. /* A quick check (type == ZEND_USER_FUNCTION || type == ZEND_EVAL_CODE) */
  725. #define ZEND_USER_CODE(type) ((type & 1) == 0)
  726. #define ZEND_INTERNAL_CLASS 1
  727. #define ZEND_USER_CLASS 2
  728. #define ZEND_EVAL (1<<0)
  729. #define ZEND_INCLUDE (1<<1)
  730. #define ZEND_INCLUDE_ONCE (1<<2)
  731. #define ZEND_REQUIRE (1<<3)
  732. #define ZEND_REQUIRE_ONCE (1<<4)
  733. #define ZEND_CT (1<<0)
  734. #define ZEND_RT (1<<1)
  735. /* global/local fetches */
  736. #define ZEND_FETCH_GLOBAL (1<<1)
  737. #define ZEND_FETCH_LOCAL (1<<2)
  738. #define ZEND_FETCH_GLOBAL_LOCK (1<<3)
  739. #define ZEND_FETCH_TYPE_MASK 0xe
  740. #define ZEND_ISEMPTY (1<<0)
  741. #define ZEND_LAST_CATCH (1<<0)
  742. #define ZEND_FREE_ON_RETURN (1<<0)
  743. #define ZEND_SEND_BY_VAL 0
  744. #define ZEND_SEND_BY_REF 1
  745. #define ZEND_SEND_PREFER_REF 2
  746. #define ZEND_DIM_IS 1
  747. #define IS_CONSTANT_UNQUALIFIED 0x010
  748. #define IS_CONSTANT_CLASS 0x080 /* __CLASS__ in trait */
  749. #define IS_CONSTANT_IN_NAMESPACE 0x100
  750. static zend_always_inline int zend_check_arg_send_type(const zend_function *zf, uint32_t arg_num, uint32_t mask)
  751. {
  752. arg_num--;
  753. if (UNEXPECTED(arg_num >= zf->common.num_args)) {
  754. if (EXPECTED((zf->common.fn_flags & ZEND_ACC_VARIADIC) == 0)) {
  755. return 0;
  756. }
  757. arg_num = zf->common.num_args;
  758. }
  759. return UNEXPECTED((zf->common.arg_info[arg_num].pass_by_reference & mask) != 0);
  760. }
  761. #define ARG_MUST_BE_SENT_BY_REF(zf, arg_num) \
  762. zend_check_arg_send_type(zf, arg_num, ZEND_SEND_BY_REF)
  763. #define ARG_SHOULD_BE_SENT_BY_REF(zf, arg_num) \
  764. zend_check_arg_send_type(zf, arg_num, ZEND_SEND_BY_REF|ZEND_SEND_PREFER_REF)
  765. #define ARG_MAY_BE_SENT_BY_REF(zf, arg_num) \
  766. zend_check_arg_send_type(zf, arg_num, ZEND_SEND_PREFER_REF)
  767. /* Quick API to check firat 12 arguments */
  768. #define MAX_ARG_FLAG_NUM 12
  769. #ifdef WORDS_BIGENDIAN
  770. # define ZEND_SET_ARG_FLAG(zf, arg_num, mask) do { \
  771. (zf)->quick_arg_flags |= ((mask) << ((arg_num) - 1) * 2); \
  772. } while (0)
  773. # define ZEND_CHECK_ARG_FLAG(zf, arg_num, mask) \
  774. (((zf)->quick_arg_flags >> (((arg_num) - 1) * 2)) & (mask))
  775. #else
  776. # define ZEND_SET_ARG_FLAG(zf, arg_num, mask) do { \
  777. (zf)->quick_arg_flags |= (((mask) << 6) << (arg_num) * 2); \
  778. } while (0)
  779. # define ZEND_CHECK_ARG_FLAG(zf, arg_num, mask) \
  780. (((zf)->quick_arg_flags >> (((arg_num) + 3) * 2)) & (mask))
  781. #endif
  782. #define QUICK_ARG_MUST_BE_SENT_BY_REF(zf, arg_num) \
  783. ZEND_CHECK_ARG_FLAG(zf, arg_num, ZEND_SEND_BY_REF)
  784. #define QUICK_ARG_SHOULD_BE_SENT_BY_REF(zf, arg_num) \
  785. ZEND_CHECK_ARG_FLAG(zf, arg_num, ZEND_SEND_BY_REF|ZEND_SEND_PREFER_REF)
  786. #define QUICK_ARG_MAY_BE_SENT_BY_REF(zf, arg_num) \
  787. ZEND_CHECK_ARG_FLAG(zf, arg_num, ZEND_SEND_PREFER_REF)
  788. #define ZEND_RETURN_VAL 0
  789. #define ZEND_RETURN_REF 1
  790. #define ZEND_BIND_VAL 0
  791. #define ZEND_BIND_REF 1
  792. #define ZEND_RETURNS_FUNCTION (1<<0)
  793. #define ZEND_RETURNS_VALUE (1<<1)
  794. #define ZEND_ARRAY_ELEMENT_REF (1<<0)
  795. #define ZEND_ARRAY_NOT_PACKED (1<<1)
  796. #define ZEND_ARRAY_SIZE_SHIFT 2
  797. /* For "use" AST nodes and the seen symbol table */
  798. #define ZEND_SYMBOL_CLASS (1<<0)
  799. #define ZEND_SYMBOL_FUNCTION (1<<1)
  800. #define ZEND_SYMBOL_CONST (1<<2)
  801. /* Pseudo-opcodes that are used only temporarily during compilation */
  802. #define ZEND_GOTO 253
  803. #define ZEND_BRK 254
  804. #define ZEND_CONT 255
  805. END_EXTERN_C()
  806. #define ZEND_CLONE_FUNC_NAME "__clone"
  807. #define ZEND_CONSTRUCTOR_FUNC_NAME "__construct"
  808. #define ZEND_DESTRUCTOR_FUNC_NAME "__destruct"
  809. #define ZEND_GET_FUNC_NAME "__get"
  810. #define ZEND_SET_FUNC_NAME "__set"
  811. #define ZEND_UNSET_FUNC_NAME "__unset"
  812. #define ZEND_ISSET_FUNC_NAME "__isset"
  813. #define ZEND_CALL_FUNC_NAME "__call"
  814. #define ZEND_CALLSTATIC_FUNC_NAME "__callstatic"
  815. #define ZEND_TOSTRING_FUNC_NAME "__tostring"
  816. #define ZEND_AUTOLOAD_FUNC_NAME "__autoload"
  817. #define ZEND_INVOKE_FUNC_NAME "__invoke"
  818. #define ZEND_DEBUGINFO_FUNC_NAME "__debuginfo"
  819. /* The following constants may be combined in CG(compiler_options)
  820. * to change the default compiler behavior */
  821. /* generate extended debug information */
  822. #define ZEND_COMPILE_EXTENDED_INFO (1<<0)
  823. /* call op_array handler of extendions */
  824. #define ZEND_COMPILE_HANDLE_OP_ARRAY (1<<1)
  825. /* generate ZEND_INIT_FCALL_BY_NAME for internal functions instead of ZEND_INIT_FCALL */
  826. #define ZEND_COMPILE_IGNORE_INTERNAL_FUNCTIONS (1<<2)
  827. /* don't perform early binding for classes inherited form internal ones;
  828. * in namespaces assume that internal class that doesn't exist at compile-time
  829. * may apper in run-time */
  830. #define ZEND_COMPILE_IGNORE_INTERNAL_CLASSES (1<<3)
  831. /* generate ZEND_DECLARE_INHERITED_CLASS_DELAYED opcode to delay early binding */
  832. #define ZEND_COMPILE_DELAYED_BINDING (1<<4)
  833. /* disable constant substitution at compile-time */
  834. #define ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION (1<<5)
  835. /* disable usage of builtin instruction for strlen() */
  836. #define ZEND_COMPILE_NO_BUILTIN_STRLEN (1<<6)
  837. /* disable substitution of persistent constants at compile-time */
  838. #define ZEND_COMPILE_NO_PERSISTENT_CONSTANT_SUBSTITUTION (1<<7)
  839. /* generate ZEND_INIT_FCALL_BY_NAME for userland functions instead of ZEND_INIT_FCALL */
  840. #define ZEND_COMPILE_IGNORE_USER_FUNCTIONS (1<<8)
  841. /* force ZEND_ACC_USE_GUARDS for all classes */
  842. #define ZEND_COMPILE_GUARDS (1<<9)
  843. /* disable builtin special case function calls */
  844. #define ZEND_COMPILE_NO_BUILTINS (1<<10)
  845. /* result of compilation may be stored in file cache */
  846. #define ZEND_COMPILE_WITH_FILE_CACHE (1<<11)
  847. /* disable jumptable optimization for switch statements */
  848. #define ZEND_COMPILE_NO_JUMPTABLES (1<<12)
  849. /* The default value for CG(compiler_options) */
  850. #define ZEND_COMPILE_DEFAULT ZEND_COMPILE_HANDLE_OP_ARRAY
  851. /* The default value for CG(compiler_options) during eval() */
  852. #define ZEND_COMPILE_DEFAULT_FOR_EVAL 0
  853. ZEND_API zend_bool zend_binary_op_produces_numeric_string_error(uint32_t opcode, zval *op1, zval *op2);
  854. #endif /* ZEND_COMPILE_H */
  855. /*
  856. * Local variables:
  857. * tab-width: 4
  858. * c-basic-offset: 4
  859. * indent-tabs-mode: t
  860. * End:
  861. * vim600: sw=4 ts=4 fdm=marker
  862. * vim<600: sw=4 ts=4
  863. */