xref: /PHP-5.6/Zend/zend_ast.h (revision 3537e95d)
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 
20 /* $Id$ */
21 
22 #ifndef ZEND_AST_H
23 #define ZEND_AST_H
24 
25 typedef struct _zend_ast zend_ast;
26 
27 #include "zend.h"
28 
29 typedef enum _zend_ast_kind {
30 	/* first 256 kinds are reserved for opcodes */
31 	ZEND_CONST = 256,
32 	ZEND_BOOL_AND,
33 	ZEND_BOOL_OR,
34 	ZEND_SELECT,
35 	ZEND_UNARY_PLUS,
36 	ZEND_UNARY_MINUS,
37 } zend_ast_kind;
38 
39 struct _zend_ast {
40 	unsigned short kind;
41 	unsigned short children;
42 	union {
43 		zval     *val;
44 		zend_ast *child;
45 	} u;
46 };
47 
48 ZEND_API zend_ast *zend_ast_create_constant(zval *zv);
49 
50 ZEND_API zend_ast *zend_ast_create_unary(uint kind, zend_ast *op0);
51 ZEND_API zend_ast *zend_ast_create_binary(uint kind, zend_ast *op0, zend_ast *op1);
52 ZEND_API zend_ast *zend_ast_create_ternary(uint kind, zend_ast *op0, zend_ast *op1, zend_ast *op2);
53 ZEND_API zend_ast* zend_ast_create_dynamic(uint kind);
54 ZEND_API void zend_ast_dynamic_add(zend_ast **ast, zend_ast *op);
55 ZEND_API void zend_ast_dynamic_shrink(zend_ast **ast);
56 
57 ZEND_API int zend_ast_is_ct_constant(zend_ast *ast);
58 
59 ZEND_API void zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *scope TSRMLS_DC);
60 
61 ZEND_API zend_ast *zend_ast_copy(zend_ast *ast);
62 ZEND_API void zend_ast_destroy(zend_ast *ast);
63 
64 #endif
65