2005-01-10 22:57:36 +08:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Zend Engine |
|
|
|
|
+----------------------------------------------------------------------+
|
2017-01-02 23:30:12 +08:00
|
|
|
| Copyright (c) 1998-2017 Zend Technologies Ltd. (http://www.zend.com) |
|
2005-01-10 22:57:36 +08:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| This source file is subject to version 2.00 of the Zend license, |
|
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
|
|
|
| available through the world-wide-web at the following url: |
|
|
|
|
| http://www.zend.com/license/2_00.txt. |
|
|
|
|
| If you did not receive a copy of the Zend license and are unable to |
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@zend.com so we can mail you a copy immediately. |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Authors: Andi Gutmans <andi@zend.com> |
|
2005-10-28 14:05:57 +08:00
|
|
|
| Zeev Suraski <zeev@zend.com> |
|
|
|
|
| Dmitry Stogov <dmitry@zend.com> |
|
2005-01-10 22:57:36 +08:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
2013-12-22 02:27:58 +08:00
|
|
|
#ifndef ZEND_VM_OPCODES_H
|
|
|
|
#define ZEND_VM_OPCODES_H
|
|
|
|
|
2015-03-16 17:00:04 +08:00
|
|
|
#define ZEND_VM_SPEC 1
|
|
|
|
#define ZEND_VM_LINES 0
|
|
|
|
#define ZEND_VM_KIND_CALL 1
|
|
|
|
#define ZEND_VM_KIND_SWITCH 2
|
|
|
|
#define ZEND_VM_KIND_GOTO 3
|
|
|
|
#define ZEND_VM_KIND ZEND_VM_KIND_CALL
|
|
|
|
|
2016-01-22 04:13:43 +08:00
|
|
|
#define ZEND_VM_OP_SPEC 0x00000001
|
|
|
|
#define ZEND_VM_OP_CONST 0x00000002
|
|
|
|
#define ZEND_VM_OP_TMPVAR 0x00000004
|
2016-03-11 18:38:53 +08:00
|
|
|
#define ZEND_VM_OP_TMPVARCV 0x00000008
|
2016-01-22 04:13:43 +08:00
|
|
|
#define ZEND_VM_OP_MASK 0x000000f0
|
|
|
|
#define ZEND_VM_OP_NUM 0x00000010
|
|
|
|
#define ZEND_VM_OP_JMP_ADDR 0x00000020
|
|
|
|
#define ZEND_VM_OP_TRY_CATCH 0x00000030
|
|
|
|
#define ZEND_VM_OP_LIVE_RANGE 0x00000040
|
|
|
|
#define ZEND_VM_OP_THIS 0x00000050
|
|
|
|
#define ZEND_VM_OP_NEXT 0x00000060
|
|
|
|
#define ZEND_VM_OP_CLASS_FETCH 0x00000070
|
|
|
|
#define ZEND_VM_OP_CONSTRUCTOR 0x00000080
|
2015-12-11 06:45:26 +08:00
|
|
|
#define ZEND_VM_EXT_VAR_FETCH 0x00010000
|
|
|
|
#define ZEND_VM_EXT_ISSET 0x00020000
|
|
|
|
#define ZEND_VM_EXT_ARG_NUM 0x00040000
|
|
|
|
#define ZEND_VM_EXT_ARRAY_INIT 0x00080000
|
|
|
|
#define ZEND_VM_EXT_REF 0x00100000
|
2016-03-11 21:51:06 +08:00
|
|
|
#define ZEND_VM_EXT_MASK 0x0f000000
|
2015-12-11 06:45:26 +08:00
|
|
|
#define ZEND_VM_EXT_NUM 0x01000000
|
|
|
|
#define ZEND_VM_EXT_JMP_ADDR 0x03000000
|
|
|
|
#define ZEND_VM_EXT_DIM_OBJ 0x04000000
|
|
|
|
#define ZEND_VM_EXT_CLASS_FETCH 0x05000000
|
|
|
|
#define ZEND_VM_EXT_CONST_FETCH 0x06000000
|
|
|
|
#define ZEND_VM_EXT_TYPE 0x07000000
|
|
|
|
#define ZEND_VM_EXT_EVAL 0x08000000
|
|
|
|
#define ZEND_VM_EXT_SRC 0x0b000000
|
2016-03-11 21:51:06 +08:00
|
|
|
#define ZEND_VM_NO_CONST_CONST 0x40000000
|
|
|
|
#define ZEND_VM_COMMUTATIVE 0x80000000
|
2016-01-22 04:13:43 +08:00
|
|
|
#define ZEND_VM_OP1_FLAGS(flags) (flags & 0xff)
|
|
|
|
#define ZEND_VM_OP2_FLAGS(flags) ((flags >> 8) & 0xff)
|
2015-10-29 04:25:05 +08:00
|
|
|
|
2014-09-25 04:00:25 +08:00
|
|
|
BEGIN_EXTERN_C()
|
|
|
|
|
2013-12-22 21:00:51 +08:00
|
|
|
ZEND_API const char *zend_get_opcode_name(zend_uchar opcode);
|
2015-10-29 04:25:05 +08:00
|
|
|
ZEND_API uint32_t zend_get_opcode_flags(zend_uchar opcode);
|
2013-12-22 06:45:34 +08:00
|
|
|
|
2014-09-25 04:00:25 +08:00
|
|
|
END_EXTERN_C()
|
|
|
|
|
2008-03-18 16:36:30 +08:00
|
|
|
#define ZEND_NOP 0
|
|
|
|
#define ZEND_ADD 1
|
|
|
|
#define ZEND_SUB 2
|
|
|
|
#define ZEND_MUL 3
|
|
|
|
#define ZEND_DIV 4
|
|
|
|
#define ZEND_MOD 5
|
|
|
|
#define ZEND_SL 6
|
|
|
|
#define ZEND_SR 7
|
|
|
|
#define ZEND_CONCAT 8
|
|
|
|
#define ZEND_BW_OR 9
|
|
|
|
#define ZEND_BW_AND 10
|
|
|
|
#define ZEND_BW_XOR 11
|
|
|
|
#define ZEND_BW_NOT 12
|
|
|
|
#define ZEND_BOOL_NOT 13
|
|
|
|
#define ZEND_BOOL_XOR 14
|
|
|
|
#define ZEND_IS_IDENTICAL 15
|
|
|
|
#define ZEND_IS_NOT_IDENTICAL 16
|
|
|
|
#define ZEND_IS_EQUAL 17
|
|
|
|
#define ZEND_IS_NOT_EQUAL 18
|
|
|
|
#define ZEND_IS_SMALLER 19
|
|
|
|
#define ZEND_IS_SMALLER_OR_EQUAL 20
|
|
|
|
#define ZEND_CAST 21
|
|
|
|
#define ZEND_QM_ASSIGN 22
|
|
|
|
#define ZEND_ASSIGN_ADD 23
|
|
|
|
#define ZEND_ASSIGN_SUB 24
|
|
|
|
#define ZEND_ASSIGN_MUL 25
|
|
|
|
#define ZEND_ASSIGN_DIV 26
|
|
|
|
#define ZEND_ASSIGN_MOD 27
|
|
|
|
#define ZEND_ASSIGN_SL 28
|
|
|
|
#define ZEND_ASSIGN_SR 29
|
|
|
|
#define ZEND_ASSIGN_CONCAT 30
|
|
|
|
#define ZEND_ASSIGN_BW_OR 31
|
|
|
|
#define ZEND_ASSIGN_BW_AND 32
|
|
|
|
#define ZEND_ASSIGN_BW_XOR 33
|
|
|
|
#define ZEND_PRE_INC 34
|
|
|
|
#define ZEND_PRE_DEC 35
|
|
|
|
#define ZEND_POST_INC 36
|
|
|
|
#define ZEND_POST_DEC 37
|
|
|
|
#define ZEND_ASSIGN 38
|
|
|
|
#define ZEND_ASSIGN_REF 39
|
|
|
|
#define ZEND_ECHO 40
|
2016-05-13 06:40:15 +08:00
|
|
|
#define ZEND_GENERATOR_CREATE 41
|
2008-03-18 16:36:30 +08:00
|
|
|
#define ZEND_JMP 42
|
|
|
|
#define ZEND_JMPZ 43
|
|
|
|
#define ZEND_JMPNZ 44
|
|
|
|
#define ZEND_JMPZNZ 45
|
|
|
|
#define ZEND_JMPZ_EX 46
|
|
|
|
#define ZEND_JMPNZ_EX 47
|
|
|
|
#define ZEND_CASE 48
|
2016-07-01 02:40:34 +08:00
|
|
|
#define ZEND_CHECK_VAR 49
|
2016-05-31 09:06:00 +08:00
|
|
|
#define ZEND_SEND_VAR_NO_REF_EX 50
|
2016-07-07 05:59:44 +08:00
|
|
|
#define ZEND_MAKE_REF 51
|
2008-03-18 16:36:30 +08:00
|
|
|
#define ZEND_BOOL 52
|
2015-03-25 03:47:21 +08:00
|
|
|
#define ZEND_FAST_CONCAT 53
|
|
|
|
#define ZEND_ROPE_INIT 54
|
|
|
|
#define ZEND_ROPE_ADD 55
|
|
|
|
#define ZEND_ROPE_END 56
|
2008-03-18 16:36:30 +08:00
|
|
|
#define ZEND_BEGIN_SILENCE 57
|
|
|
|
#define ZEND_END_SILENCE 58
|
|
|
|
#define ZEND_INIT_FCALL_BY_NAME 59
|
|
|
|
#define ZEND_DO_FCALL 60
|
2014-06-30 19:43:45 +08:00
|
|
|
#define ZEND_INIT_FCALL 61
|
2008-03-18 16:36:30 +08:00
|
|
|
#define ZEND_RETURN 62
|
|
|
|
#define ZEND_RECV 63
|
|
|
|
#define ZEND_RECV_INIT 64
|
|
|
|
#define ZEND_SEND_VAL 65
|
2014-07-08 06:13:53 +08:00
|
|
|
#define ZEND_SEND_VAR_EX 66
|
2008-03-18 16:36:30 +08:00
|
|
|
#define ZEND_SEND_REF 67
|
|
|
|
#define ZEND_NEW 68
|
|
|
|
#define ZEND_INIT_NS_FCALL_BY_NAME 69
|
|
|
|
#define ZEND_FREE 70
|
|
|
|
#define ZEND_INIT_ARRAY 71
|
|
|
|
#define ZEND_ADD_ARRAY_ELEMENT 72
|
|
|
|
#define ZEND_INCLUDE_OR_EVAL 73
|
|
|
|
#define ZEND_UNSET_VAR 74
|
|
|
|
#define ZEND_UNSET_DIM 75
|
|
|
|
#define ZEND_UNSET_OBJ 76
|
2015-02-12 18:57:12 +08:00
|
|
|
#define ZEND_FE_RESET_R 77
|
|
|
|
#define ZEND_FE_FETCH_R 78
|
2008-03-18 16:36:30 +08:00
|
|
|
#define ZEND_EXIT 79
|
|
|
|
#define ZEND_FETCH_R 80
|
|
|
|
#define ZEND_FETCH_DIM_R 81
|
|
|
|
#define ZEND_FETCH_OBJ_R 82
|
|
|
|
#define ZEND_FETCH_W 83
|
|
|
|
#define ZEND_FETCH_DIM_W 84
|
|
|
|
#define ZEND_FETCH_OBJ_W 85
|
|
|
|
#define ZEND_FETCH_RW 86
|
|
|
|
#define ZEND_FETCH_DIM_RW 87
|
|
|
|
#define ZEND_FETCH_OBJ_RW 88
|
|
|
|
#define ZEND_FETCH_IS 89
|
|
|
|
#define ZEND_FETCH_DIM_IS 90
|
|
|
|
#define ZEND_FETCH_OBJ_IS 91
|
|
|
|
#define ZEND_FETCH_FUNC_ARG 92
|
|
|
|
#define ZEND_FETCH_DIM_FUNC_ARG 93
|
|
|
|
#define ZEND_FETCH_OBJ_FUNC_ARG 94
|
|
|
|
#define ZEND_FETCH_UNSET 95
|
|
|
|
#define ZEND_FETCH_DIM_UNSET 96
|
|
|
|
#define ZEND_FETCH_OBJ_UNSET 97
|
2014-10-05 17:02:58 +08:00
|
|
|
#define ZEND_FETCH_LIST 98
|
2008-03-18 16:36:30 +08:00
|
|
|
#define ZEND_FETCH_CONSTANT 99
|
|
|
|
#define ZEND_EXT_STMT 101
|
|
|
|
#define ZEND_EXT_FCALL_BEGIN 102
|
|
|
|
#define ZEND_EXT_FCALL_END 103
|
|
|
|
#define ZEND_EXT_NOP 104
|
|
|
|
#define ZEND_TICKS 105
|
|
|
|
#define ZEND_SEND_VAR_NO_REF 106
|
|
|
|
#define ZEND_CATCH 107
|
|
|
|
#define ZEND_THROW 108
|
|
|
|
#define ZEND_FETCH_CLASS 109
|
|
|
|
#define ZEND_CLONE 110
|
2010-04-22 19:56:45 +08:00
|
|
|
#define ZEND_RETURN_BY_REF 111
|
2008-03-18 16:36:30 +08:00
|
|
|
#define ZEND_INIT_METHOD_CALL 112
|
|
|
|
#define ZEND_INIT_STATIC_METHOD_CALL 113
|
|
|
|
#define ZEND_ISSET_ISEMPTY_VAR 114
|
|
|
|
#define ZEND_ISSET_ISEMPTY_DIM_OBJ 115
|
2014-07-08 06:13:53 +08:00
|
|
|
#define ZEND_SEND_VAL_EX 116
|
|
|
|
#define ZEND_SEND_VAR 117
|
2014-07-11 04:32:18 +08:00
|
|
|
#define ZEND_INIT_USER_CALL 118
|
|
|
|
#define ZEND_SEND_ARRAY 119
|
|
|
|
#define ZEND_SEND_USER 120
|
2014-07-11 22:52:27 +08:00
|
|
|
#define ZEND_STRLEN 121
|
2014-07-14 19:43:11 +08:00
|
|
|
#define ZEND_DEFINED 122
|
2014-07-14 14:33:11 +08:00
|
|
|
#define ZEND_TYPE_CHECK 123
|
2015-01-09 04:40:36 +08:00
|
|
|
#define ZEND_VERIFY_RETURN_TYPE 124
|
2015-02-12 18:57:12 +08:00
|
|
|
#define ZEND_FE_RESET_RW 125
|
|
|
|
#define ZEND_FE_FETCH_RW 126
|
|
|
|
#define ZEND_FE_FREE 127
|
2015-02-25 03:29:47 +08:00
|
|
|
#define ZEND_INIT_DYNAMIC_CALL 128
|
2015-02-25 15:37:21 +08:00
|
|
|
#define ZEND_DO_ICALL 129
|
|
|
|
#define ZEND_DO_UCALL 130
|
|
|
|
#define ZEND_DO_FCALL_BY_NAME 131
|
2008-03-18 16:36:30 +08:00
|
|
|
#define ZEND_PRE_INC_OBJ 132
|
|
|
|
#define ZEND_PRE_DEC_OBJ 133
|
|
|
|
#define ZEND_POST_INC_OBJ 134
|
|
|
|
#define ZEND_POST_DEC_OBJ 135
|
|
|
|
#define ZEND_ASSIGN_OBJ 136
|
2015-04-20 05:21:57 +08:00
|
|
|
#define ZEND_OP_DATA 137
|
2008-03-18 16:36:30 +08:00
|
|
|
#define ZEND_INSTANCEOF 138
|
|
|
|
#define ZEND_DECLARE_CLASS 139
|
|
|
|
#define ZEND_DECLARE_INHERITED_CLASS 140
|
|
|
|
#define ZEND_DECLARE_FUNCTION 141
|
2015-04-14 23:58:58 +08:00
|
|
|
#define ZEND_YIELD_FROM 142
|
2008-03-18 16:36:30 +08:00
|
|
|
#define ZEND_DECLARE_CONST 143
|
|
|
|
#define ZEND_ADD_INTERFACE 144
|
|
|
|
#define ZEND_DECLARE_INHERITED_CLASS_DELAYED 145
|
|
|
|
#define ZEND_VERIFY_ABSTRACT_CLASS 146
|
|
|
|
#define ZEND_ASSIGN_DIM 147
|
|
|
|
#define ZEND_ISSET_ISEMPTY_PROP_OBJ 148
|
|
|
|
#define ZEND_HANDLE_EXCEPTION 149
|
|
|
|
#define ZEND_USER_OPCODE 150
|
2015-03-02 17:25:40 +08:00
|
|
|
#define ZEND_ASSERT_CHECK 151
|
2008-03-18 16:36:30 +08:00
|
|
|
#define ZEND_JMP_SET 152
|
2008-07-14 17:49:03 +08:00
|
|
|
#define ZEND_DECLARE_LAMBDA_FUNCTION 153
|
Implemented Traits for PHP as proposed in the RFC [TRAITS]
# RFC http://wiki.php.net/rfc/horizontalreuse#traits_-_reuse_of_behavior
# Ok, here we go, I guess that will result in more discussion, which is fine
# by me. But now, the patch is here, and properly archived.
#
# See below a list of notes to the patch, it also includes a list of
# points which should be fixed
#
# Internals of the Traits Patch
# -----------------------------
#
# Open TODOs
# """"""""""
#
# - Reflection API
# - support for traits for internal classes
# - currently destroy_zend_class does not handle that case
#
# Introduced Structures
# """""""""""""""""""""
#
# Data structures to encode the composition information specified in the
# source:
# - zend_trait_method_reference
# - zend_trait_precedence
# - zend_trait_alias
#
# Changes
# """""""
#
# zend_class_entry
# - uses NULL terminated lists of pointers for
# - trait_aliases
# - trait_precedences
# - do you prefer an explicit counter?
# - the information is only necessary during class composition
# but might be interesting for reflection
# - did not want to blow up class further with not really necessary length counters
#
# added keywords
# - trait
# - insteadof
#
# Added opcodes
# ZEND_ADD_TRAIT
# - similar to ZEND_ADD_INTERFACE
# - adds the trait to the list of traits of a class, no actual composition done
# ZEND_BIND_TRAITS
# - emitted in zend_do_end_class_declaration
# - concludes the class definition and will initiate the trait composition
# when the class definition is encountered during runtime
#
# Added Flags
# ZEND_ACC_TRAIT = 0x120
# ZEND_ACC_IMPLEMENT_TRAITS = 0x400000
# ZEND_FETCH_CLASS_TRAIT = 14
#
# zend_vm_execute.h
# - not sure whether the handler initialization (ZEND_ADD_TRAIT_SPEC_HANDLER,
# ZEND_BIND_TRAITS_SPEC_HANDLER) is correct, maybe it should be more selective
#
# zend_compile.c
# - refactored do_inherit_method_check
# split into do_inherit_method_check and do_inheritance_check_on_method
# - added helper functions use a '_' as prefix and are not mentioned in the
# headers
# - _copy_functions
# prepare hash-maps of functions which should be merged into a class
# here the aliases are handled
# - _merge_functions
# builds a hash-table of the methods which need to be added to a class
# does the conflict detection
# - reused php_runkit_function_copy_ctor
# - it is not identical with the original code anymore, needed to update it
# think I fixed some bugs, not sure whether all have been reported back to runkit
# - has to be renamed, left the name for the moment, to make its origin obvious
# - here might be optimization potential
# - not sure whether everything needs to be copied
# - copying the literals might be broken
# - added it since the literals array is freed by efree and gave problems
# with doubled frees
# - all immutable parts of the zend_op array should not be copied
# - am not sure which parts are immutable
# - and not sure how to avoid doubled frees on the same arrays on shutdown
# - _merge_functions_to_class
# does the final merging with the target class to handle inherited
# and overridden methods
# - small helper for NULL terminated lists
# zend_init_list, zend_add_to_list
#
# zend_language_parser.y
# - reused class definition for traits
# - there should be something with regard to properties
# - if they get explicitly defined, it might be worthwhile to
# check that there are no collisions with other traits in a composition
# (however, I would not introduce elaborate language features to control that
# but a notice for such conflicts might be nice to the developers)
2010-04-23 06:05:56 +08:00
|
|
|
#define ZEND_ADD_TRAIT 154
|
|
|
|
#define ZEND_BIND_TRAITS 155
|
2010-08-25 17:14:36 +08:00
|
|
|
#define ZEND_SEPARATE 156
|
2015-03-18 20:31:29 +08:00
|
|
|
#define ZEND_FETCH_CLASS_NAME 157
|
2015-04-11 04:01:00 +08:00
|
|
|
#define ZEND_CALL_TRAMPOLINE 158
|
2012-12-13 06:48:51 +08:00
|
|
|
#define ZEND_DISCARD_EXCEPTION 159
|
2012-08-13 22:51:41 +08:00
|
|
|
#define ZEND_YIELD 160
|
2012-08-26 01:03:23 +08:00
|
|
|
#define ZEND_GENERATOR_RETURN 161
|
2012-11-22 19:17:05 +08:00
|
|
|
#define ZEND_FAST_CALL 162
|
|
|
|
#define ZEND_FAST_RET 163
|
2013-09-27 00:39:17 +08:00
|
|
|
#define ZEND_RECV_VARIADIC 164
|
2013-08-29 17:35:11 +08:00
|
|
|
#define ZEND_SEND_UNPACK 165
|
2013-11-19 15:36:06 +08:00
|
|
|
#define ZEND_POW 166
|
|
|
|
#define ZEND_ASSIGN_POW 167
|
2014-06-06 19:04:30 +08:00
|
|
|
#define ZEND_BIND_GLOBAL 168
|
2014-09-17 02:14:46 +08:00
|
|
|
#define ZEND_COALESCE 169
|
2015-01-19 15:12:39 +08:00
|
|
|
#define ZEND_SPACESHIP 170
|
2015-04-27 17:24:39 +08:00
|
|
|
#define ZEND_DECLARE_ANON_CLASS 171
|
|
|
|
#define ZEND_DECLARE_ANON_INHERITED_CLASS 172
|
2015-10-27 20:47:58 +08:00
|
|
|
#define ZEND_FETCH_STATIC_PROP_R 173
|
|
|
|
#define ZEND_FETCH_STATIC_PROP_W 174
|
|
|
|
#define ZEND_FETCH_STATIC_PROP_RW 175
|
|
|
|
#define ZEND_FETCH_STATIC_PROP_IS 176
|
|
|
|
#define ZEND_FETCH_STATIC_PROP_FUNC_ARG 177
|
|
|
|
#define ZEND_FETCH_STATIC_PROP_UNSET 178
|
|
|
|
#define ZEND_UNSET_STATIC_PROP 179
|
|
|
|
#define ZEND_ISSET_ISEMPTY_STATIC_PROP 180
|
|
|
|
#define ZEND_FETCH_CLASS_CONSTANT 181
|
2015-12-29 18:16:08 +08:00
|
|
|
#define ZEND_BIND_LEXICAL 182
|
2016-01-12 17:20:35 +08:00
|
|
|
#define ZEND_BIND_STATIC 183
|
2016-06-16 07:30:23 +08:00
|
|
|
#define ZEND_FETCH_THIS 184
|
|
|
|
#define ZEND_ISSET_ISEMPTY_THIS 186
|
2013-12-22 02:27:58 +08:00
|
|
|
|
2016-06-16 07:30:23 +08:00
|
|
|
#define ZEND_VM_LAST_OPCODE 186
|
2015-10-29 14:15:37 +08:00
|
|
|
|
2013-12-26 17:45:37 +08:00
|
|
|
#endif
|