+ struct type_class_struct *_struct_class =
+ container_of(type_class, struct type_class_struct, p);
+ struct type_struct *_struct;
+
+ _struct = g_new(struct type_struct, 1);
+ type_class_ref(&_struct_class->p);
+ _struct->p._class = _struct_class;
+ _struct->p.ref = 1;
+ _struct->scope = new_declaration_scope(parent_scope);
+ _struct->fields = g_array_sized_new(FALSE, TRUE,
+ sizeof(struct field),
+ DEFAULT_NR_STRUCT_FIELDS);
+ return &_struct->p;
+}
+
+static
+void _struct_type_free(struct type *type)
+{
+ struct type_struct *_struct = container_of(type, struct type_struct, p);
+ unsigned long i;
+
+ for (i = 0; i < _struct->fields->len; i++) {
+ struct field *field = &g_array_index(_struct->fields,
+ struct field, i);
+ type_unref(field->type);
+ }
+ free_declaration_scope(_struct->scope);
+ type_class_unref(_struct->p._class);
+ g_free(_struct);
+}
+
+void struct_type_class_add_field(struct type_class_struct *struct_class,
+ const char *field_name,
+ struct type_class *type_class)
+{
+ struct type_class_field *field;