+void psi_data_dump(struct psi_dump *dump, struct psi_data *D)
+{
+ size_t i = 0;
+ char *libname;
+
+ if (D->file.filename) {
+ PSI_DUMP(dump, "// filename=%s (%u errors)\n", D->file.filename->val, D->errors);
+ }
+ while (psi_plist_get(D->file.libnames, i++, &libname)) {
+ PSI_DUMP(dump, "lib \"%s\";\n", libname);
+ }
+ if (psi_plist_count(D->types)) {
+ size_t i = 0;
+ struct psi_decl_arg *def;
+
+ while (psi_plist_get(D->types, i++, &def)) {
+ PSI_DUMP(dump, "typedef ");
+ psi_decl_arg_dump(dump, def, 0);
+ PSI_DUMP(dump, ";\n");
+ }
+ PSI_DUMP(dump, "\n");
+ }
+ if (psi_plist_count(D->unions)) {
+ size_t i = 0;
+ struct psi_decl_union *unn;
+
+ while (psi_plist_get(D->unions, i++, &unn)) {
+ if (!psi_decl_type_is_anon(unn->name, "union")) {
+ psi_decl_union_dump(dump, unn);
+ PSI_DUMP(dump, "\n");
+ }
+ }
+ PSI_DUMP(dump, "\n");
+ }
+ if (psi_plist_count(D->structs)) {
+ size_t i = 0;
+ struct psi_decl_struct *strct;
+
+ while (psi_plist_get(D->structs, i++, &strct)) {
+ if (!psi_decl_type_is_anon(strct->name, "struct")) {
+ psi_decl_struct_dump(dump, strct);
+ PSI_DUMP(dump, "\n");
+ }
+ }
+ PSI_DUMP(dump, "\n");
+ }
+ if (psi_plist_count(D->enums)) {
+ size_t i = 0;
+ struct psi_decl_enum *enm;
+
+ while (psi_plist_get(D->enums, i++, &enm)) {
+ if (true || !psi_decl_type_is_anon(enm->name, "enum")) {
+ psi_decl_enum_dump(dump, enm, 0);
+ PSI_DUMP(dump, "\n");
+ }
+ }
+ PSI_DUMP(dump, "\n");
+ }
+ if (psi_plist_count(D->consts)) {
+ size_t i = 0;
+ struct psi_const *c;
+
+ while (psi_plist_get(D->consts, i++, &c)) {
+ psi_const_dump(dump, c);
+ PSI_DUMP(dump, "\n");
+ }
+ PSI_DUMP(dump, "\n");
+ }
+ if (psi_plist_count(D->decls)) {
+ size_t i = 0;
+ struct psi_decl *decl;
+
+ while (psi_plist_get(D->decls, i++, &decl)) {
+ if (decl->extvar) {
+ PSI_DUMP(dump, "/* extvar accessor \n");
+ }
+ psi_decl_dump(dump, decl);
+ if (decl->extvar) {
+ PSI_DUMP(dump, " */");
+ }
+ PSI_DUMP(dump, "\n");
+ }
+ PSI_DUMP(dump, "\n");
+ }
+ if (psi_plist_count(D->vars)) {
+ size_t i = 0;
+ struct psi_decl_extvar *evar;
+
+ while (psi_plist_get(D->vars, i++, &evar)) {
+ psi_decl_extvar_dump(dump, evar);
+ }
+ PSI_DUMP(dump, "\n");
+ }
+ if (psi_plist_count(D->impls)) {
+ size_t i = 0;
+ struct psi_impl *impl;
+
+ while (psi_plist_get(D->impls, i++, &impl)) {
+ psi_impl_dump(dump, impl);
+ PSI_DUMP(dump, "\n");
+ }
+ PSI_DUMP(dump, "\n");
+ }
+}