zend_ast.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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: Bob Weinand <bwoebi@php.net> |
  16. | Dmitry Stogov <dmitry@zend.com> |
  17. +----------------------------------------------------------------------+
  18. */
  19. /* $Id$ */
  20. #ifndef ZEND_AST_H
  21. #define ZEND_AST_H
  22. typedef struct _zend_ast zend_ast;
  23. #include "zend.h"
  24. typedef enum _zend_ast_kind {
  25. /* first 256 kinds are reserved for opcodes */
  26. ZEND_CONST = 256,
  27. ZEND_BOOL_AND,
  28. ZEND_BOOL_OR,
  29. ZEND_SELECT,
  30. ZEND_UNARY_PLUS,
  31. ZEND_UNARY_MINUS,
  32. } zend_ast_kind;
  33. struct _zend_ast {
  34. unsigned short kind;
  35. unsigned short children;
  36. union {
  37. zval *val;
  38. zend_ast *child;
  39. } u;
  40. };
  41. ZEND_API zend_ast *zend_ast_create_constant(zval *zv);
  42. ZEND_API zend_ast *zend_ast_create_unary(uint kind, zend_ast *op0);
  43. ZEND_API zend_ast *zend_ast_create_binary(uint kind, zend_ast *op0, zend_ast *op1);
  44. ZEND_API zend_ast *zend_ast_create_ternary(uint kind, zend_ast *op0, zend_ast *op1, zend_ast *op2);
  45. ZEND_API zend_ast* zend_ast_create_dynamic(uint kind);
  46. ZEND_API void zend_ast_dynamic_add(zend_ast **ast, zend_ast *op);
  47. ZEND_API void zend_ast_dynamic_shrink(zend_ast **ast);
  48. ZEND_API int zend_ast_is_ct_constant(zend_ast *ast);
  49. ZEND_API void zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *scope TSRMLS_DC);
  50. ZEND_API zend_ast *zend_ast_copy(zend_ast *ast);
  51. ZEND_API void zend_ast_destroy(zend_ast *ast);
  52. #endif