33 lines
733 B
C
33 lines
733 B
C
#include <blue/ds/string.h>
|
|
#include <mie/dialect/dialect.h>
|
|
#include <mie/type/type-definition.h>
|
|
|
|
struct mie_type_definition *mie_type_definition_create(
|
|
struct mie_dialect *parent, const char *name)
|
|
{
|
|
struct mie_type_definition *out = malloc(sizeof *out);
|
|
if (!out) {
|
|
return NULL;
|
|
}
|
|
|
|
out->ty_name = b_strdup(name);
|
|
if (!out->ty_name) {
|
|
free(out);
|
|
return NULL;
|
|
}
|
|
|
|
out->ty_parent = parent;
|
|
mie_trait_table_init(&out->ty_traits);
|
|
|
|
b_rope name_rope = B_ROPE_CSTR(name);
|
|
mie_id_map_put(&parent->d_types, &out->ty_id, &name_rope);
|
|
|
|
return out;
|
|
}
|
|
|
|
enum mie_status mie_type_definition_add_trait(
|
|
struct mie_type_definition *type, const struct mie_trait *trait)
|
|
{
|
|
return mie_trait_table_put(&type->ty_traits, trait);
|
|
}
|