X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=blobdiff_plain;f=src%2Fcontext.c;h=3fe6c3f17af72acf303c95c4cbe040550578f2a3;hp=1887a7c0146533b2b37fce2b4b175490d19475ce;hb=6a459a08a40a2c243b0211ceb0cb263d29302627;hpb=b4a3c33fc143fd57288fcfe0878e7a22eeaf61bf diff --git a/src/context.c b/src/context.c index 1887a7c..3fe6c3f 100644 --- a/src/context.c +++ b/src/context.c @@ -26,7 +26,7 @@ #include "php.h" #include "php_scandir.h" #include "php_psi.h" - +#include "calc.h" #include "libjit.h" #include "libffi.h" @@ -137,7 +137,7 @@ PSI_Context *PSI_ContextInit(PSI_Context *C, PSI_ContextOps *ops, PSI_ContextErr predef_decl = farg; } - PSI_ContextValidatePredef(C, &T); + PSI_ContextValidateData(PSI_DATA(C), &T); C->count = 1; C->data = malloc(sizeof(*C->data)); @@ -220,13 +220,12 @@ void PSI_ContextBuild(PSI_Context *C, const char *paths) 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]; @@ -247,6 +246,22 @@ zend_function_entry *PSI_ContextCompile(PSI_Context *C) 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); } @@ -301,6 +316,12 @@ void PSI_ContextDtor(PSI_Context *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);