- 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);
-
- 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);
- }