X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=blobdiff_plain;f=src%2Fcontext.c;h=f580f7f424bb70a8fd3d9fcd0a9ee9900539a55c;hp=5b08426a96bfecf7692b14b0a482508f6b207615;hb=574519ef5e3ab76f00253fad870afce7135638d1;hpb=35914cd494aac5ca32868ed4e791ccef04d5216d diff --git a/src/context.c b/src/context.c index 5b08426..f580f7f 100644 --- a/src/context.c +++ b/src/context.c @@ -105,8 +105,6 @@ #include "php.h" #include "php_scandir.h" #include "php_psi.h" -#include "context.h" -#include "parser.h" #include "libjit.h" #include "libffi.h" @@ -163,11 +161,26 @@ int psi_glob(const char *pattern, int flags, return rv; } +int psi_printf(const char *fmt, ...) { + int rs; + char *a1; + va_list ap1, ap2; + + va_start(ap1, fmt); + va_copy(ap2, ap1); + a1 = va_arg(ap2, char *); + rs = vprintf(fmt, ap1); + va_end(ap1); + va_end(ap2); + return rs; +} + static struct psi_func_redir { const char *name; void (*func)(void); } psi_func_redirs[] = { {"glob", (void (*)(void)) psi_glob}, + {"printf", (void (*)(void)) psi_printf}, PSI_REDIRS {0} }; @@ -294,8 +307,10 @@ static inline int validate_constant(PSI_Data *data, constant *c) { static inline int validate_decl_arg(PSI_Data *data, decl_arg *arg) { if (!validate_decl_type(data, arg->type)) { - data->error(PSI_WARNING, "Cannot use '%s'(%d) as type for '%s'", - arg->type->name, arg->type->type, arg->var->name); + data->error(PSI_WARNING, "Cannot use '%s'(%d) as type for decl var '%s'" + " in %s on line %zu at col %zu", + arg->type->name, arg->type->type, arg->var->name, + arg->type->token->file, arg->type->token->line, arg->type->token->col); return 0; } return 1; @@ -1214,9 +1229,9 @@ zend_function_entry *PSI_ContextCompile(PSI_Context *C) } -void PSI_ContextCall(PSI_Context *C, impl_val *ret_val, decl *decl) +void PSI_ContextCall(PSI_Context *C, decl_callinfo *decl_call, impl_vararg *va) { - C->ops->call(C, ret_val, decl); + C->ops->call(C, decl_call, va); } static inline void dump_decl_type(int fd, decl_type *t) { @@ -1371,11 +1386,16 @@ void PSI_ContextDump(PSI_Context *C, int fd) dprintf(fd, "%s ", decl->abi->convention); dump_decl_arg(fd, decl->func); dprintf(fd, "("); - if (decl->args) for (j = 0; j < decl->args->count; ++j) { - if (j) { - dprintf(fd, ", "); + if (decl->args) { + for (j = 0; j < decl->args->count; ++j) { + if (j) { + dprintf(fd, ", "); + } + dump_decl_arg(fd, decl->args->args[j]); + } + if (decl->args->varargs) { + dprintf(fd, ", ..."); } - dump_decl_arg(fd, decl->args->args[j]); } dprintf(fd, ");\n"); } @@ -1386,16 +1406,26 @@ void PSI_ContextDump(PSI_Context *C, int fd) impl *impl = C->impls->list[i]; dprintf(fd, "function %s(", impl->func->name); - if (impl->func->args) for (j = 0; j < impl->func->args->count; ++j) { - impl_arg *iarg = impl->func->args->args[j]; - - dprintf(fd, "%s%s %s$%s", - j ? ", " : "", - iarg->type->name, - iarg->var->reference ? "&" : "", - iarg->var->name); - if (iarg->def) { - dprintf(fd, " = %s", iarg->def->text); + if (impl->func->args) { + for (j = 0; j < impl->func->args->count; ++j) { + impl_arg *iarg = impl->func->args->args[j]; + + dprintf(fd, "%s%s %s$%s", + j ? ", " : "", + iarg->type->name, + iarg->var->reference ? "&" : "", + iarg->var->name); + if (iarg->def) { + dprintf(fd, " = %s", iarg->def->text); + } + } + if (impl->func->args->vararg.name) { + impl_arg *vararg = impl->func->args->vararg.name; + + dprintf(fd, ", %s %s...$%s", + vararg->type->name, + vararg->var->reference ? "&" : "", + vararg->var->name); } } dprintf(fd, ") : %s%s {\n",