From: Michael Wallner Date: Mon, 15 Feb 2016 10:33:14 +0000 (+0100) Subject: fix dump X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=cbdcfd25784d00b309573f5e2de35538e9efa8af;p=m6w6%2Fext-psi fix dump --- diff --git a/src/context_dump.c b/src/context_dump.c index 8e11eca..72c82b3 100644 --- a/src/context_dump.c +++ b/src/context_dump.c @@ -57,8 +57,10 @@ static inline void dump_decl_var(int fd, decl_var *v) { static inline void dump_decl_arg(int fd, decl_arg *a) { dump_decl_type(fd, a->type); - dprintf(fd, " "); - dump_decl_var(fd, a->var); + if (a->type->type != PSI_T_FUNCTION) { + dprintf(fd, " "); + dump_decl_var(fd, a->var); + } } static inline void dump_level(int fd, unsigned level) { @@ -307,7 +309,7 @@ static inline void dump_impl_func(int fd, impl_func *func) { for (j = 0; j < func->args->count; ++j) { impl_arg *iarg = func->args->args[j]; - dprintf(fd, "%s%s %s$%s", + dprintf(fd, "%s%s %s%s", j ? ", " : "", iarg->type->name, iarg->var->reference ? "&" : "", @@ -319,7 +321,7 @@ static inline void dump_impl_func(int fd, impl_func *func) { if (func->args->vararg.name) { impl_arg *vararg = func->args->vararg.name; - dprintf(fd, ", %s %s...$%s", + dprintf(fd, ", %s %s...%s", vararg->type->name, vararg->var->reference ? "&" : "", vararg->var->name); @@ -348,8 +350,23 @@ static inline void dump_impl_let_stmt(int fd, let_stmt *let) { dump_num_exp(fd, let->val->data.alloc->size); dprintf(fd, ")"); break; + case PSI_LET_CALLBACK: + dprintf(fd, "callback %s(%s(", let->val->data.callback->func->name, + let->val->data.callback->func->var->name); + if (let->val->data.callback->args) { + size_t i, c = let->val->data.callback->args->count; + + dprintf(fd, "\n"); + for (i = 0; i < c; ++i) { + set_value *set = let->val->data.callback->args->vals[i]; + dump_impl_set_value(fd, set, 2, i + 1 == c); + } + dprintf(fd, "\t"); + } + dprintf(fd, "));"); + break; case PSI_LET_FUNC: - dprintf(fd, "%s($%s)", let->val->data.func->name, + dprintf(fd, "%s(%s)", let->val->data.func->name, let->val->data.func->var->name); break; case PSI_LET_NUMEXP: @@ -368,7 +385,7 @@ static inline void dump_impl_return_stmt(int fd, return_stmt *ret) { } static inline void dump_impl_set_stmt(int fd, set_stmt *set) { - dprintf(fd, "\tset $%s = ", set->var->name); + dprintf(fd, "\tset %s = ", set->var->name); dump_impl_set_value(fd, set->val, 1, 0); } diff --git a/tests/sqlite/sqlite.psi b/tests/sqlite/sqlite.psi index 23669d6..b2beb5c 100644 --- a/tests/sqlite/sqlite.psi +++ b/tests/sqlite/sqlite.psi @@ -42,13 +42,6 @@ function sqlite3\open(string $uri, object &$db) : int { typedef int (*sqlite3_callback)(void *data, int argc, char** argv, char** cols); -/* - * C calls into us, so we have to have a way to define how the callback - * arguments have to be marshaled for the userland callback, i.e. from - * native C types to ZE zvals /and/ how the userland return value has - * to be marshaled to a native type. All in all, the opposite of function impls. - */ - extern int sqlite3_exec(sqlite3 *db, const char *sql, sqlite3_callback callback, void *data, char **errmsg); function sqlite3\exec(object $db, string $sql, callable $cb, mixed $cd, string &$error = null) : int { let db = objval($db);