This repository has been archived by the owner on Nov 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
php_zephir.h
145 lines (121 loc) · 4.45 KB
/
php_zephir.h
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
+--------------------------------------------------------------------------+
| Zephir Language |
+--------------------------------------------------------------------------+
| Copyright (c) 2013-2014 Zephir Team and contributors |
+--------------------------------------------------------------------------+
| This source file is subject the MIT license, that is bundled with |
| this package in the file LICENSE, and is available through the |
| world-wide-web at the following url: |
| http://zephir-lang.com/license.html |
| |
| If you did not receive a copy of the MIT license and are unable |
| to obtain it through the world-wide-web, please send a note to |
| [email protected] so we can mail you a copy immediately. |
+--------------------------------------------------------------------------+
*/
#ifndef PHP_ZEPHIR_RUNTIME_H
#define PHP_ZEPHIR_RUNTIME_H 1
#include <llvm-c/Analysis.h>
#include <llvm-c/Target.h>
#include <llvm-c/Transforms/Scalar.h>
#include <llvm-c/ExecutionEngine.h>
#define ZEPHIR_RELEASE 1
#define PHP_ZEPHIR_VERSION "0.0.1"
#define PHP_ZEPHIR_EXTNAME "zephir"
/** Memory frame */
typedef struct _zephir_memory_entry {
size_t pointer;
size_t capacity;
zval ***addresses;
size_t hash_pointer;
size_t hash_capacity;
zval ***hash_addresses;
struct _zephir_memory_entry *prev;
struct _zephir_memory_entry *next;
#ifndef ZEPHIR_RELEASE
const char *func;
#endif
} zephir_memory_entry;
/** Virtual Symbol Table */
typedef struct _zephir_symbol_table {
struct _zephir_memory_entry *scope;
HashTable *symbol_table;
struct _zephir_symbol_table *prev;
} zephir_symbol_table;
typedef struct _zephir_function_cache {
zend_class_entry *ce;
zend_function *func;
} zephir_function_cache;
ZEND_BEGIN_MODULE_GLOBALS(zephir)
/* Memory */
zephir_memory_entry *start_memory; /**< The first preallocated frame */
zephir_memory_entry *end_memory; /**< The last preallocate frame */
zephir_memory_entry *active_memory; /**< The current memory frame */
/* Virtual Symbol Tables */
zephir_symbol_table *active_symbol_table;
/** Function cache */
HashTable *fcache;
/* Max recursion control */
unsigned int recursive_lock;
LLVMModuleRef module;
LLVMBuilderRef builder;
LLVMExecutionEngineRef engine;
LLVMPassManagerRef pass_manager;
ZEND_END_MODULE_GLOBALS(zephir)
#ifdef ZTS
#include "TSRM.h"
#endif
ZEND_EXTERN_MODULE_GLOBALS(zephir)
#ifdef ZTS
#define ZEPHIRT_GLOBAL(v) TSRMG(zephir_globals_id, zend_zephir_globals *, v)
#else
#define ZEPHIRT_GLOBAL(v) (zephir_globals.v)
#endif
#ifdef ZTS
#define ZEPHIRT_VGLOBAL ((zend_zephir_globals *) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(zend_globals_id)])
#else
#define ZEPHIRT_VGLOBAL &(zephir_globals)
#endif
#if defined(__GNUC__) && (defined(__clang__) || ((__GNUC__ * 100 + __GNUC_MINOR__) >= 405))
# define UNREACHABLE() __builtin_unreachable()
# define ASSUME(x) if (x) {} else __builtin_unreachable()
#else
# define UNREACHABLE() assert(0)
# define ASSUME(x) assert(!!(x));
#endif
/** Define FASTCALL */
#if defined(__GNUC__) && ZEND_GCC_VERSION >= 3004 && defined(__i386__)
# define ZEPHIR_FASTCALL __attribute__((fastcall))
#elif defined(_MSC_VER) && defined(_M_IX86)
# define ZEPHIR_FASTCALL __fastcall
#else
# define ZEPHIR_FASTCALL
#endif
#if defined(__GNUC__) || defined(__clang__)
# define ZEPHIR_ATTR_NONNULL __attribute__((nonnull))
# define ZEPHIR_ATTR_NONNULL1(x) __attribute__((nonnull (x)))
# define ZEPHIR_ATTR_NONNULL2(x, y) __attribute__((nonnull (x, y)))
# define ZEPHIR_ATTR_NONNULL3(x, y, z) __attribute__((nonnull (x, y, z)))
# define ZEPHIR_ATTR_PURE __attribute__((pure))
# define ZEPHIR_ATTR_CONST __attribute__((const))
# define ZEPHIR_ATTR_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
#else
# define ZEPHIR_ATTR_NONNULL
# define ZEPHIR_ATTR_NONNULL1(x)
# define ZEPHIR_ATTR_NONNULL2(x, y)
# define ZEPHIR_ATTR_NONNULL3(x, y, z)
# define ZEPHIR_ATTR_PURE
# define ZEPHIR_ATTR_CONST
# define ZEPHIR_ATTR_WARN_UNUSED_RESULT
#endif
#if defined(__x86_64__) || defined(_M_X64)
#define ZEPHIR_64 1
#define ZEPHIR_32 0
#elif defined(__i386) || defined(_M_IX86)
#define ZEPHIR_64 0
#define ZEPHIR_32 1
#endif
extern zend_module_entry zephir_module_entry;
#define phpext_zephir_ptr &zephir_module_entry
#endif