#include "php.h"
#include "php_scandir.h"
#include "php_psi.h"
-
+#include "calc.h"
#include "libjit.h"
#include "libffi.h"
predef_decl = farg;
}
- PSI_ContextValidatePredef(C, &T);
+ PSI_ContextValidateData(PSI_DATA(C), &T);
C->count = 1;
C->data = malloc(sizeof(*C->data));
zend_function_entry *PSI_ContextCompile(PSI_Context *C)
{
size_t i;
+ zend_constant zc;
- if (C->consts) {
- zend_constant zc;
-
- zc.flags = CONST_PERSISTENT|CONST_CS;
- zc.module_number = EG(current_module)->module_number;
+ zc.flags = CONST_PERSISTENT|CONST_CS;
+ zc.module_number = EG(current_module)->module_number;
+ if (C->consts) {
for (i = 0; i < C->consts->count; ++i) {
constant *c = C->consts->list[i];
zend_register_constant(&zc);
}
}
+ if (C->enums) {
+ for (i = 0; i < C->enums->count; ++i) {
+ decl_enum *e = C->enums->list[i];
+ size_t j;
+
+ for (j = 0; j < e->items->count; ++j) {
+ decl_enum_item *i = e->items->list[j];
+ zend_string *name = strpprintf(0, "psi\\%s\\%s", e->name, i->name);
+
+ zc.name = zend_string_dup(name, 1);
+ ZVAL_LONG(&zc.value, psi_long_num_exp(i->num, NULL));
+ zend_register_constant(&zc);
+ zend_string_release(name);
+ }
+ }
+ }
return C->closures = C->ops->compile(C);
}
}
free(C->structs);
}
+ if (C->enums) {
+ if (C->enums->list) {
+ free(C->enums->list);
+ }
+ free(C->enums);
+ }
if (C->decls) {
if (C->decls->list) {
free(C->decls->list);