inner let vals
[m6w6/ext-psi] / src / types.h
1 #ifndef _PSI_TYPES_H
2 #define _PSI_TYPES_H
3
4 #include "Zend/zend_API.h"
5 typedef struct zend_fcall {
6 zend_fcall_info fci;
7 zend_fcall_info_cache fcc;
8 } zend_fcall;
9
10 #include "token.h"
11
12 #include "types/impl_val.h"
13 #include "types/decl_type.h"
14 #include "types/decl_var.h"
15 #include "types/decl_struct_layout.h"
16 #include "types/decl_arg.h"
17 #include "types/decl_typedefs.h"
18 #include "types/decl_vars.h"
19 #include "types/decl_args.h"
20 #include "types/decl_abi.h"
21 #include "types/decl_callinfo.h"
22 #include "types/decl.h"
23 #include "types/decls.h"
24 #include "types/decl_struct.h"
25 #include "types/decl_structs.h"
26 #include "types/decl_union.h"
27 #include "types/decl_unions.h"
28 #include "types/impl_type.h"
29 #include "types/impl_var.h"
30 #include "types/impl_def_val.h"
31 #include "types/const_type.h"
32 #include "types/constant.h"
33 #include "types/constants.h"
34 #include "types/impl_arg.h"
35 #include "types/impl_args.h"
36 #include "types/impl_func.h"
37 #include "types/num_exp.h"
38 #include "types/decl_enum_item.h"
39 #include "types/decl_enum_items.h"
40 #include "types/decl_enum.h"
41 #include "types/decl_enums.h"
42 #include "types/let_calloc.h"
43 #include "types/let_callback.h"
44 #include "types/let_func.h"
45 #include "types/let_val.h"
46 #include "types/let_vals.h"
47 #include "types/let_stmt.h"
48 #include "types/set_func.h"
49 #include "types/set_value.h"
50 #include "types/set_values.h"
51 #include "types/set_stmt.h"
52 #include "types/return_stmt.h"
53 #include "types/free_call.h"
54 #include "types/free_calls.h"
55 #include "types/free_stmt.h"
56 #include "types/impl_stmt.h"
57 #include "types/impl_stmts.h"
58 #include "types/impl.h"
59 #include "types/impls.h"
60 #include "types/decl_file.h"
61 #include "types/decl_libs.h"
62
63
64 static inline int weak_decl_type(decl_type *type) {
65 switch (type->type) {
66 case PSI_T_CHAR:
67 case PSI_T_SHORT:
68 case PSI_T_INT:
69 case PSI_T_LONG:
70 case PSI_T_NAME:
71 return type->type;
72 default:
73 return 0;
74 }
75 }
76
77 static inline decl_type *real_decl_type(decl_type *type) {
78 while (weak_decl_type(type)) {
79 type = type->real.def->type;
80 }
81 return type;
82 }
83
84 static inline impl_val *deref_impl_val(impl_val *ret_val, decl_var *var) {
85 unsigned i;
86
87 ZEND_ASSERT(var->arg->var != var);
88 #if 0
89 fprintf(stderr, "deref: %s pl=%u:%u as=%u:%u %p\n",
90 var->name, var->pointer_level, var->arg->var->pointer_level,
91 var->array_size, var->arg->var->array_size, ret_val);
92 #endif
93 for (i = 0; i < var->pointer_level; ++i) {
94 #if 0
95 fprintf(stderr, "-- %p %p %p\n", ret_val, *(void**)ret_val, ret_val->ptr);
96 #endif
97 ret_val = *(void **) ret_val;
98 }
99 return ret_val;
100 }
101
102 static inline impl_val *enref_impl_val(void *ptr, decl_var *var) {
103 impl_val *val, *val_ptr;
104 unsigned i;
105
106 ZEND_ASSERT(var->arg->var == var);
107 #if 0
108 fprintf(stderr, "enref: %s pl=%u:%u as=%u:%u\n",
109 var->name, var->pointer_level, var->arg->var->pointer_level,
110 var->array_size, var->arg->var->array_size);
111 #endif
112 if (!var->pointer_level ){//&& real_decl_type(var->arg->type)->type != PSI_T_STRUCT) {
113 return ptr;
114 }
115
116 val = val_ptr = calloc(var->pointer_level + 1, sizeof(void *));
117 for (i = !var->arg->var->array_size; i < var->pointer_level; ++i) {
118 #if 0
119 fprintf(stderr, "++\n");
120 #endif
121 val_ptr->ptr = (void **) val_ptr + 1;
122 val_ptr = val_ptr->ptr;
123 }
124 val_ptr->ptr = ptr;
125 return val;
126 }
127
128 static inline impl_val *struct_member_ref(decl_arg *set_arg, impl_val *struct_ptr, impl_val **to_free) {
129 void *ptr = (char *) struct_ptr + set_arg->layout->pos;
130 #if 0
131 fprintf(stderr, "struct member %s: %p\n", set_arg->var->name, ptr);
132 #endif
133 return ptr;
134 }
135
136
137 #define PSI_ERROR 16
138 #define PSI_WARNING 32
139 typedef void (*psi_error_cb)(void *context, struct psi_token *token, int type, const char *msg, ...);
140
141 #endif