- /* only if inner stmts, i.e. with new lines, were dumped */
- dump_level(fd, level);
- }
- if (level > 1) {
- dprintf(fd, "),\n");
- } else {
- dprintf(fd, ");\n");
- }
-}
-void PSI_ContextDump(PSI_Context *C, int fd)
-{
- size_t i, j, k, l;
-
-#ifdef HAVE_LIBJIT
- if (C->ops == PSI_Libjit()) {
- dprintf(fd, "// psi.engine=jit\n");
- }
-#endif
-#ifdef HAVE_LIBFFI
- if (C->ops == PSI_Libffi()) {
- dprintf(fd, "// psi.engine=ffi\n");
- }
-#endif
- dprintf(fd, "\n");
-
- if (C->defs) {
- for (i = 0; i < C->defs->count; ++i) {
- decl_typedef *tdef = C->defs->list[i];
-
- dprintf(fd, "typedef ");
- dump_decl_type(fd, tdef->type);
- dprintf(fd, " %s;\n", tdef->alias);
- }
- dprintf(fd, "\n");
- }
-
- if (C->structs) {
- for (i = 0; i < C->structs->count; ++i) {
- decl_struct *strct = C->structs->list[i];
-
- dprintf(fd, "struct %s::(%zu) {\n", strct->name, strct->size);
- if (strct->args) for (j = 0; j < strct->args->count; ++j) {
- decl_arg *sarg = strct->args->args[j];
-
- dprintf(fd, "\t");
- dump_decl_arg(fd, sarg);
- dprintf(fd, "::(%zu, %zu);\n", sarg->layout->pos, sarg->layout->len);
- }
- dprintf(fd, "}\n");
- }
- dprintf(fd, "\n");
- }
- if (C->consts) {
- for (i = 0; i < C->consts->count; ++i) {
- constant *cnst = C->consts->list[i];
-
- dprintf(fd, "const %s %s = ", cnst->type->name, cnst->name);
- if (cnst->val->type == PSI_T_QUOTED_STRING) {
- dprintf(fd, "\"%s\";\n", cnst->val->text);
- } else {
- dprintf(fd, "%s;\n", cnst->val->text);
- }
- }
- dprintf(fd, "\n");
- }
- if (C->decls) {
- for (i = 0; i < C->decls->count; ++i) {
- decl *decl = C->decls->list[i];
-
- 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, ", ");
- }
- dump_decl_arg(fd, decl->args->args[j]);
- }
- if (decl->args->varargs) {
- dprintf(fd, ", ...");
- }
- }
- dprintf(fd, ");\n");
- }
- dprintf(fd, "\n");