source: trunk/xcache/xc_opcode_spec.c

Last change on this file was 1321, checked in by moo, 15 months ago

add back PHP_4 code for disassembler

  • Property svn:eol-style set to native
File size: 1.3 KB
Line 
1#include "xcache.h"
2#include "xc_opcode_spec.h"
3#include "xc_const_string.h"
4
5/* {{{ opcode_spec */
6#define OPSPEC(ext, op1, op2, res) { OPSPEC_##ext, OPSPEC_##op1, OPSPEC_##op2, OPSPEC_##res },
7#ifdef ZEND_ENGINE_2
8#   define OPSPEC_VAR_2 OPSPEC_STD
9#else
10#   define OPSPEC_VAR_2 OPSPEC_VAR
11#endif
12#ifdef ZEND_ENGINE_2_4
13#undef OPSPEC_FETCH
14#define OPSPEC_FETCH OPSPEC_STD
15#endif
16#include "xc_opcode_spec_def.h"
17
18zend_uchar xc_get_opcode_spec_count()
19{
20    return sizeof(xc_opcode_spec) / sizeof(xc_opcode_spec[0]);
21}
22
23const xc_opcode_spec_t *xc_get_opcode_spec(zend_uchar opcode)
24{
25#ifndef NDEBUG
26    if (xc_get_opcode_count() != xc_get_opcode_spec_count()) {
27        fprintf(stderr, "count mismatch: xc_get_opcode_count=%d, xc_get_opcode_spec_count=%d\n", xc_get_opcode_count(), xc_get_opcode_spec_count());
28    }
29#endif
30    assert(xc_get_opcode_count() == xc_get_opcode_spec_count());
31    assert(opcode < xc_get_opcode_spec_count());
32    return &xc_opcode_spec[opcode];
33}
34/* }}} */
35/* {{{ op_spec */
36
37#define OPSPECS_DEF_NAME(name) #name,
38static const char *xc_op_spec[] = { OPSPECS(OPSPECS_DEF_NAME) };
39
40zend_uchar xc_get_op_spec_count()
41{
42    return sizeof(xc_op_spec) / sizeof(xc_op_spec[0]);
43}
44
45const char *xc_get_op_spec(zend_uchar spec)
46{
47    assert(spec < xc_get_op_spec_count());
48    return xc_op_spec[spec];
49}
50/* }}} */
Note: See TracBrowser for help on using the repository browser.