- struct_class = g_new(struct type_class_struct, 1);
- type_class = &struct_class->p;
-
- struct_class->fields_by_name = g_hash_table_new(g_direct_hash,
- g_direct_equal);
- struct_class->fields = g_array_sized_new(false, false,
- sizeof(struct field),
- DEFAULT_NR_STRUCT_FIELDS);
- type_class->name = g_quark_from_string(name);
- type_class->alignment = 1;
- type_class->copy = struct_copy;
- type_class->free = _struct_type_free;
- type_class->ref = 1;
-
- if (type_class->name) {
- ret = register_type(type_class);
- if (ret)
- goto error_register;
+ _struct = g_new(struct definition_struct, 1);
+ declaration_ref(&struct_declaration->p);
+ _struct->p.declaration = declaration;
+ _struct->declaration = struct_declaration;
+ _struct->p.ref = 1;
+ _struct->p.index = index;
+ _struct->scope = new_definition_scope(parent_scope, field_name);
+ _struct->fields = g_array_sized_new(FALSE, TRUE,
+ sizeof(struct field),
+ DEFAULT_NR_STRUCT_FIELDS);
+ g_array_set_size(_struct->fields, struct_declaration->fields->len);
+ for (i = 0; i < struct_declaration->fields->len; i++) {
+ struct declaration_field *declaration_field =
+ &g_array_index(struct_declaration->fields,
+ struct declaration_field, i);
+ struct field *field = &g_array_index(_struct->fields,
+ struct field, i);
+
+ field->name = declaration_field->name;
+ field->definition =
+ declaration_field->declaration->definition_new(declaration_field->declaration,
+ _struct->scope,
+ field->name, i);
+ ret = register_field_definition(field->name,
+ field->definition,
+ _struct->scope);
+ assert(!ret);