+ for (predef_composite = &psi_predef_composites[0]; predef_composite->type_tag; ++predef_composite) {
+ struct psi_predef_composite *member;
+ struct psi_decl_struct *dstruct;
+ struct psi_decl_union *dunion;
+ struct psi_plist *dargs = psi_plist_init((psi_plist_dtor) psi_decl_arg_free);
+
+ switch (predef_composite->type_tag) {
+ case PSI_T_STRUCT:
+ dstruct = psi_decl_struct_init(predef_composite->var_name, dargs);
+ dstruct->size = predef_composite->size;
+ dstruct->align = predef_composite->offset;
+ break;
+ case PSI_T_UNION:
+ dunion = psi_decl_union_init(predef_composite->var_name, dargs);
+ dunion->size = predef_composite->size;
+ dunion->align = predef_composite->offset;
+ break;
+ default:
+ assert(0);
+ }
+ for (member = &predef_composite[1]; member->type_tag; ++member) {
+ struct psi_decl_type *type;
+ struct psi_decl_var *dvar;
+ struct psi_decl_arg *darg;
+
+ type = psi_decl_type_init(member->type_tag, member->type_name);
+ dvar = psi_decl_var_init(member->var_name, member->pointer_level, member->array_size);
+ darg = psi_decl_arg_init(type, dvar);
+ darg->layout = psi_layout_init(member->offset, member->size, NULL);
+
+ switch (predef_composite->type_tag) {
+ case PSI_T_STRUCT:
+ dstruct->args = psi_plist_add(dstruct->args, &darg);
+ break;
+ case PSI_T_UNION:
+ dunion->args = psi_plist_add(dunion->args, &darg);
+ break;
+ default:
+ assert(0);
+ }
+ }
+ switch (predef_composite->type_tag) {
+ case PSI_T_STRUCT:
+ T.structs = psi_plist_add(T.structs, &dstruct);
+ break;
+ case PSI_T_UNION:
+ T.unions = psi_plist_add(T.unions, &dunion);
+ break;
+ default:
+ assert(0);
+ }
+
+ predef_composite = member;
+ }
+ for (predef_decl = &psi_predef_decls[0]; predef_decl->type_tag; ++predef_decl) {
+ struct psi_predef_decl *farg;
+ struct psi_decl_type *dtype, *ftype = psi_decl_type_init(predef_decl->type_tag, predef_decl->type_name);
+ struct psi_decl_var *fname = psi_decl_var_init(predef_decl->var_name, predef_decl->pointer_level, predef_decl->array_size);
+ struct psi_decl_arg *tdef, *func = psi_decl_arg_init(ftype, fname);
+ struct psi_plist *args = psi_plist_init((psi_plist_dtor) psi_decl_arg_free);
+ struct psi_decl *decl = psi_decl_init(func, args);
+
+ for (farg = &predef_decl[1]; farg->type_tag; ++farg) {
+ struct psi_decl_type *arg_type = psi_decl_type_init(farg->type_tag, farg->type_name);
+ struct psi_decl_var *arg_var = psi_decl_var_init(farg->var_name, farg->pointer_level, farg->array_size);
+ struct psi_decl_arg *darg = psi_decl_arg_init(arg_type, arg_var);
+ decl->args = psi_plist_add(decl->args, &darg);
+ }
+
+ switch (predef_decl->kind) {
+ case DECL_KIND_VARARG:
+ decl->varargs = 1;
+ /* no break */
+ case DECL_KIND_STD:
+ T.decls = psi_plist_add(T.decls, &decl);
+ break;
+ case DECL_KIND_FUNCTOR:
+ dtype = psi_decl_type_init(PSI_T_FUNCTION, fname->name);
+ dtype->real.func = decl;
+ tdef = psi_decl_arg_init(dtype, psi_decl_var_copy(fname));
+ T.types = psi_plist_add(T.types, &tdef);
+ break;
+ default:
+ assert(0);
+ }
+
+ predef_decl = farg;
+ }
+
+ psi_context_add_data(C, &T);
+