summaryrefslogtreecommitdiff
path: root/xcache/xc_const_string.c
blob: 94f48da1485bf45a442043122bf87b9770242871 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include "xcache.h"
#include "xc_const_string.h"

/* {{{ xc_get_op_type */
static const char *const op_type_names[] = {
	/* 0 */ "NULL?",
	/* 1 */ "IS_CONST",
	/* 2 */ "IS_TMP_VAR",
	/* 3 */ NULL,
	/* 4 */ "IS_VAR",
	/* 5 */ NULL,
	/* 6 */ NULL,
	/* 7 */ NULL,
	/* 8 */ "IS_UNUSED",
#ifdef IS_CV
	/* 9  */ NULL,
	/* 10 */ NULL,
	/* 11 */ NULL,
	/* 12 */ NULL,
	/* 13 */ NULL,
	/* 14 */ NULL,
	/* 15 */ NULL,
	/* 16 */ "IS_CV"
#endif
};

zend_uchar xc_get_op_type_count()
{
	return sizeof(op_type_names) / sizeof(op_type_names[0]);
}

const char *xc_get_op_type(zend_uchar op_type)
{
	assert(op_type < xc_get_op_type_count());
	return op_type_names[op_type];
}
/* }}} */
/* {{{ xc_get_data_type */
static const char *const data_type_names[] = {
	/* 0 */ "IS_NULL",
	/* 1 */ "IS_LONG",
	/* 2 */ "IS_DOUBLE",
#ifdef ZEND_ENGINE_2_1
	/* 3 */ "IS_BOOL",
#else
	/* 6 */ "IS_STRING",
#endif
	/* 4 */ "IS_ARRAY",
	/* 5 */ "IS_OBJECT",
#ifdef ZEND_ENGINE_2_1
	/* 6 */ "IS_STRING",
#else
	/* 3 */ "IS_BOOL",
#endif
	/* 7 */ "IS_RESOURCE",
	/* 8 */ "IS_CONSTANT",
	/* 9 */ "IS_CONSTANT_ARRAY",
	/* 10 */ "IS_UNICODE"
};

zend_uchar xc_get_data_type_count()
{
	return sizeof(data_type_names) / sizeof(data_type_names[0]);
}

const char *xc_get_data_type(zend_uchar data_type)
{
	return data_type_names[(data_type & IS_CONSTANT_TYPE_MASK)];
}
/* }}} */
/* {{{ xc_get_opcode */
#if PHP_MAJOR_VERSION >= 6
#	include "xc_const_string_opcodes_php6.x.h"
#elif defined(ZEND_ENGINE_2_5)
#	include "xc_const_string_opcodes_php5.5.h"
#elif defined(ZEND_ENGINE_2_4)
#	include "xc_const_string_opcodes_php5.4.h"
#elif defined(ZEND_ENGINE_2_3)
#	include "xc_const_string_opcodes_php5.3.h"
#elif defined(ZEND_ENGINE_2_2)
#	include "xc_const_string_opcodes_php5.2.h"
#elif defined(ZEND_ENGINE_2_1)
#	include "xc_const_string_opcodes_php5.1.h"
#elif defined(ZEND_ENGINE_2)
#	include "xc_const_string_opcodes_php5.0.h"
#else
#	include "xc_const_string_opcodes_php4.x.h"
#endif

zend_uchar xc_get_opcode_count()
{
	return sizeof(xc_opcode_names) / sizeof(xc_opcode_names[0]);
}

const char *xc_get_opcode(zend_uchar opcode)
{
	assert(opcode < xc_get_opcode_count());
	return xc_opcode_names[opcode];
}
/* }}} */