X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Fcontext.c;h=8bd2deef155d1b20da822b217b65e686ed49cde0;hb=ef5079cd02c9d8666f6b9336853d2ab393e33467;hp=3fe6c3f17af72acf303c95c4cbe040550578f2a3;hpb=6a459a08a40a2c243b0211ceb0cb263d29302627;p=m6w6%2Fext-psi diff --git a/src/context.c b/src/context.c index 3fe6c3f..8bd2dee 100644 --- a/src/context.c +++ b/src/context.c @@ -37,7 +37,7 @@ #include "php_psi_structs.h" -PSI_Context *PSI_ContextInit(PSI_Context *C, PSI_ContextOps *ops, PSI_ContextErrorFunc error) +PSI_Context *PSI_ContextInit(PSI_Context *C, PSI_ContextOps *ops, PSI_ContextErrorFunc error, unsigned flags) { PSI_Data T; struct psi_predef_type *predef_type; @@ -51,6 +51,7 @@ PSI_Context *PSI_ContextInit(PSI_Context *C, PSI_ContextOps *ops, PSI_ContextErr memset(C, 0, sizeof(*C)); C->error = error; + C->flags = flags; C->ops = ops; if (ops->init) { @@ -66,7 +67,8 @@ PSI_Context *PSI_ContextInit(PSI_Context *C, PSI_ContextOps *ops, PSI_ContextErr for (predef_type = &psi_predef_types[0]; predef_type->type_tag; ++predef_type) { decl_type *type = init_decl_type(predef_type->type_tag, predef_type->type_name); - decl_typedef *def = init_decl_typedef(predef_type->alias, type); + decl_var *var = init_decl_var(predef_type->alias, 0, 0); /* FIXME: indirection */ + decl_arg *def = init_decl_arg(type, var); T.defs = add_decl_typedef(T.defs, def); } @@ -156,11 +158,10 @@ static int psi_select_dirent(const struct dirent *entry) void PSI_ContextBuild(PSI_Context *C, const char *paths) { - int i, n, flags = psi_check_env("PSI_DEBUG") ? PSI_PARSER_DEBUG : 0; + int i, n; char *sep = NULL, *cpy = strdup(paths), *ptr = cpy; struct dirent **entries = NULL; - do { sep = strchr(ptr, ':'); @@ -176,11 +177,11 @@ void PSI_ContextBuild(PSI_Context *C, const char *paths) PSI_Parser P; if (MAXPATHLEN <= slprintf(psi, MAXPATHLEN, "%s/%s", ptr, entries[i]->d_name)) { - C->error(NULL, PSI_WARNING, "Path to PSI file too long: %s/%s", + C->error(C, NULL, PSI_WARNING, "Path to PSI file too long: %s/%s", ptr, entries[i]->d_name); } - if (!PSI_ParserInit(&P, psi, C->error, flags)) { - C->error(NULL, PSI_WARNING, "Failed to init PSI parser (%s): %s", + if (!PSI_ParserInit(&P, psi, C->error, C->flags)) { + C->error(C, NULL, PSI_WARNING, "Failed to init PSI parser (%s): %s", psi, strerror(errno)); continue; } @@ -210,7 +211,7 @@ void PSI_ContextBuild(PSI_Context *C, const char *paths) if (PSI_ContextCompile(C) && SUCCESS != zend_register_functions(NULL, C->closures, NULL, MODULE_PERSISTENT)) { - C->error(NULL, PSI_WARNING, "Failed to register functions!"); + C->error(C, NULL, PSI_WARNING, "Failed to register functions!"); } free(cpy);