X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=blobdiff_plain;f=src%2Fcontext.c;h=ba587201926ffafc0286fce4b8c76d1dc8fdf491;hp=ef9cc40490a209a26f7fb806efe5c6ade6066fd0;hb=43f9e142088705cc003bb021a32ecd4d4d3b3d2b;hpb=d59f10e81c33354ee1589fb10847b4611423de2e diff --git a/src/context.c b/src/context.c index ef9cc40..ba58720 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" @@ -294,8 +292,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; @@ -699,9 +699,13 @@ static inline int validate_impl_let_stmts(PSI_Data *data, impl *impl) { /* e.g. let foo = *bar; */ let->var->pointer_level = let->val->data.var->pointer_level; let->var->arg = init_decl_arg( - init_decl_type(real_decl_type(let->val->data.var->arg->type)->type, + init_decl_type( + real_decl_type(let->val->data.var->arg->type)->type, real_decl_type(let->val->data.var->arg->type)->name), - init_decl_var(let->var->name, let->var->pointer_level, let->var->array_size)); + init_decl_var( + let->var->name, + let->var->pointer_level, + let->var->array_size)); break; case PSI_LET_NUMEXP: if (!validate_num_exp(data, impl->decl->args, impl->decl->func, let->val->data.num)) { @@ -1210,9 +1214,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) { - C->ops->call(C, ret_val, decl); + C->ops->call(C, decl_call); } static inline void dump_decl_type(int fd, decl_type *t) { @@ -1367,11 +1371,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"); } @@ -1382,16 +1391,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) { + impl_arg *vararg = impl->func->args->vararg; + + dprintf(fd, ", %s %s...$%s", + vararg->type->name, + vararg->var->reference ? "&" : "", + vararg->var->name); } } dprintf(fd, ") : %s%s {\n",