fix dump
authorMichael Wallner <mike@php.net>
Mon, 15 Feb 2016 10:33:14 +0000 (11:33 +0100)
committerMichael Wallner <mike@php.net>
Mon, 15 Feb 2016 10:33:14 +0000 (11:33 +0100)
src/context_dump.c
tests/sqlite/sqlite.psi

index 8e11eca41763589155de8a03fed85780aa463a01..72c82b37f3649e9b17e0c141ab236bf6f521cd0f 100644 (file)
@@ -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);
 }
 
index 23669d6eb4501530ff4adfdbfd548ac8a7ad2842..b2beb5cd6d4be0b5ade4d28fdf8a1a36e7addd3a 100644 (file)
@@ -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);