-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathqb_native_compiler.h
123 lines (94 loc) · 3.39 KB
/
qb_native_compiler.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
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2012 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP 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.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Chung Leong <cleong@cal.berkeley.edu> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifndef QB_NATIVE_COMPILER_H_
#define QB_NATIVE_COMPILER_H_
#ifdef NATIVE_COMPILE_ENABLED
typedef struct qb_native_compiler_context qb_native_compiler_context;
typedef enum qb_access_method qb_access_method;
enum qb_access_method {
QB_SCALAR_LITERAL = 0,
QB_SCALAR_LOCAL_VARIABLE,
QB_SCALAR_POINTER,
QB_SCALAR_ELEMENT,
QB_ARRAY_POINTER,
QB_ARRAY_POINTER_POINTER,
QB_ARRAY_SLICE,
QB_SCALAR_UNUSED = -1,
QB_ARRAY_UNUSED = -1,
};
#define QB_NATIVE_FUNCTION_RET void
#define QB_NATIVE_FUNCTION_ATTR
#define QB_NATIVE_FUNCTION_ARGS qb_interpreter_context *__restrict cxt
typedef QB_NATIVE_FUNCTION_RET (QB_NATIVE_FUNCTION_ATTR *qb_native_proc)(QB_NATIVE_FUNCTION_ARGS);
struct qb_native_compiler_context {
FILE *write_stream;
FILE *read_stream;
FILE *error_stream;
qb_compiler_context **compiler_contexts;
uint32_t compiler_context_count;
qb_data_pool *pool;
qb_op **ops;
uint32_t op_count;
qb_variable **variables;
uint32_t variable_count;
qb_address **constant_scalars;
uint32_t constant_scalar_count;
qb_address **writable_scalars;
uint32_t writable_scalar_count;
qb_address **constant_arrays;
uint32_t constant_array_count;
qb_address **writable_arrays;
uint32_t writable_array_count;
qb_address *zero_address;
qb_address *one_address;
qb_external_symbol *external_symbols;
uint32_t external_symbol_count;
qb_function *compiled_function;
qb_storage *storage;
char * const *op_names;
char * const *op_actions;
int32_t * const *op_function_usages;
char * const *function_prototypes;
char *cache_folder_path;
char *obj_file_path;
char *c_file_path;
uint64_t file_id;
uint32_t qb_version;
#ifdef _MSC_VER
HANDLE msc_thread;
HANDLE msc_process;
#endif
char *binary;
uint32_t binary_size;
int32_t print_errors;
int32_t print_source;
#ifdef ZTS
void ***tsrm_ls;
#endif
uint32_t string_buffer_index;
char string_buffers[16][128];
};
extern qb_native_symbol global_native_symbols[];
extern uint32_t global_native_symbol_count;
void qb_free_native_code(qb_native_code_bundle *bundle);
void qb_compile_to_native_code(qb_native_compiler_context *cxt);
void qb_initialize_native_compiler_context(qb_native_compiler_context *cxt, qb_build_context *build_cxt TSRMLS_DC);
void qb_free_native_compiler_context(qb_native_compiler_context *cxt);
#endif
#endif