diff --git a/mie/dialect/arith/addf.c b/mie/dialect/arith/addf.c new file mode 100644 index 0000000..a77c2e1 --- /dev/null +++ b/mie/dialect/arith/addf.c @@ -0,0 +1,18 @@ +#include +#include +#include + +static enum mie_status print(const struct mie_op *op, b_stream *out) +{ + return MIE_SUCCESS; +} + +static enum mie_status parse(struct mie_parser *parser, struct mie_op *out) +{ + return MIE_SUCCESS; +} + +MIE_DIALECT_OP_BEGIN(mie_arith_addf, "addf") + MIE_DIALECT_OP_PRINT(print); + MIE_DIALECT_OP_PARSE(parse); +MIE_DIALECT_OP_END() diff --git a/mie/dialect/arith/addi.c b/mie/dialect/arith/addi.c new file mode 100644 index 0000000..f4fae8f --- /dev/null +++ b/mie/dialect/arith/addi.c @@ -0,0 +1,18 @@ +#include +#include +#include + +static enum mie_status print(const struct mie_op *op, b_stream *out) +{ + return MIE_SUCCESS; +} + +static enum mie_status parse(struct mie_parser *parser, struct mie_op *out) +{ + return MIE_SUCCESS; +} + +MIE_DIALECT_OP_BEGIN(mie_arith_addi, "addi") + MIE_DIALECT_OP_PRINT(print); + MIE_DIALECT_OP_PARSE(parse); +MIE_DIALECT_OP_END() diff --git a/mie/dialect/arith/arith.c b/mie/dialect/arith/arith.c new file mode 100644 index 0000000..0ee75bd --- /dev/null +++ b/mie/dialect/arith/arith.c @@ -0,0 +1,9 @@ +#include +#include + +MIE_DIALECT_BEGIN(mie_arith, "arith") + MIE_DIALECT_ADD_TYPE(mie_arith_int); + MIE_DIALECT_ADD_TYPE(mie_arith_float); + MIE_DIALECT_ADD_OP(mie_arith_addi); + MIE_DIALECT_ADD_OP(mie_arith_addf); +MIE_DIALECT_END() diff --git a/mie/dialect/arith/float.c b/mie/dialect/arith/float.c new file mode 100644 index 0000000..46e602b --- /dev/null +++ b/mie/dialect/arith/float.c @@ -0,0 +1,27 @@ +#include +#include +#include + +struct float_type { + struct mie_dialect_type f_base; + size_t f_width; +}; + +static enum mie_status print( + const struct mie_dialect_type *def, const struct mie_type *ty, b_stream *out) +{ + return MIE_SUCCESS; +} + +static enum mie_status parse( + const struct mie_dialect_type *def, struct mie_parser *parser, + struct mie_type **out) +{ + return MIE_SUCCESS; +} + +MIE_DIALECT_TYPE_BEGIN(mie_arith_float, "float") + MIE_DIALECT_TYPE_STRUCT(struct float_type); + MIE_DIALECT_TYPE_PRINT(print); + MIE_DIALECT_TYPE_PARSE(parse); +MIE_DIALECT_TYPE_END() diff --git a/mie/dialect/arith/int.c b/mie/dialect/arith/int.c new file mode 100644 index 0000000..5be5c68 --- /dev/null +++ b/mie/dialect/arith/int.c @@ -0,0 +1,62 @@ +#include +#include +#include +#include +#include +#include + +struct int_type { + struct mie_type i_base; + size_t i_width; +}; + +struct mie_type *mie_arith_int_get_type(struct mie_ctx *ctx, size_t bit_width) +{ + struct mie_dialect_type *type_info + = mie_ctx_get_dialect_type(ctx, "arith", "int"); + if (!type_info) { + return NULL; + } + + b_rope rope_i = B_ROPE_CHAR('i'), rope_width = B_ROPE_UINT(bit_width); + b_rope type_name; + b_rope_concat(&type_name, &rope_i, &rope_width); + + mie_id id; + mie_id_init_ns(&id, mie_id_map_get_ns(&ctx->ctx_types), &type_name); + + mie_id *target = mie_id_map_get(&ctx->ctx_types, &id); + if (target) { + return b_unbox(struct mie_type, target, ty_id); + } + + struct int_type *type = (struct int_type *)mie_type_create(type_info); + if (!type) { + return NULL; + } + + type->i_base.ty_name = b_bstr_fmt("arith.int<%zu>", bit_width); + type->i_width = bit_width; + + mie_id_map_put(&ctx->ctx_types, &type->i_base.ty_id, &type_name); + return (struct mie_type *)type; +} + +static enum mie_status print( + const struct mie_dialect_type *def, const struct mie_type *ty, b_stream *out) +{ + return MIE_SUCCESS; +} + +static enum mie_status parse( + const struct mie_dialect_type *def, struct mie_parser *parser, + struct mie_type **out) +{ + return MIE_SUCCESS; +} + +MIE_DIALECT_TYPE_BEGIN(mie_arith_int, "int") + MIE_DIALECT_TYPE_STRUCT(struct int_type); + MIE_DIALECT_TYPE_PRINT(print); + MIE_DIALECT_TYPE_PARSE(parse); +MIE_DIALECT_TYPE_END() diff --git a/mie/dialect/builtin/builtin.c b/mie/dialect/builtin/builtin.c new file mode 100644 index 0000000..9eaf868 --- /dev/null +++ b/mie/dialect/builtin/builtin.c @@ -0,0 +1,5 @@ +#include +#include + +MIE_DIALECT_BEGIN(mie_builtin, "builtin") +MIE_DIALECT_END() diff --git a/mie/dialect/cf/br-cond.c b/mie/dialect/cf/br-cond.c new file mode 100644 index 0000000..e8f97f8 --- /dev/null +++ b/mie/dialect/cf/br-cond.c @@ -0,0 +1,18 @@ +#include +#include +#include + +static enum mie_status print(const struct mie_op *op, b_stream *out) +{ + return MIE_SUCCESS; +} + +static enum mie_status parse(struct mie_parser *parser, struct mie_op *out) +{ + return MIE_SUCCESS; +} + +MIE_DIALECT_OP_BEGIN(mie_cf_br_cond, "br-cond") + MIE_DIALECT_OP_PRINT(print); + MIE_DIALECT_OP_PARSE(parse); +MIE_DIALECT_OP_END() diff --git a/mie/dialect/cf/br.c b/mie/dialect/cf/br.c new file mode 100644 index 0000000..58275a6 --- /dev/null +++ b/mie/dialect/cf/br.c @@ -0,0 +1,18 @@ +#include +#include +#include + +static enum mie_status print(const struct mie_op *op, b_stream *out) +{ + return MIE_SUCCESS; +} + +static enum mie_status parse(struct mie_parser *parser, struct mie_op *out) +{ + return MIE_SUCCESS; +} + +MIE_DIALECT_OP_BEGIN(mie_cf_br, "br") + MIE_DIALECT_OP_PRINT(print); + MIE_DIALECT_OP_PARSE(parse); +MIE_DIALECT_OP_END() diff --git a/mie/dialect/cf/cf.c b/mie/dialect/cf/cf.c new file mode 100644 index 0000000..2713947 --- /dev/null +++ b/mie/dialect/cf/cf.c @@ -0,0 +1,7 @@ +#include +#include + +MIE_DIALECT_BEGIN(mie_cf, "cf") + MIE_DIALECT_ADD_OP(mie_cf_br); + MIE_DIALECT_ADD_OP(mie_cf_br_cond); +MIE_DIALECT_END() diff --git a/mie/dialect/dialect.c b/mie/dialect/dialect.c new file mode 100644 index 0000000..121b3a9 --- /dev/null +++ b/mie/dialect/dialect.c @@ -0,0 +1,61 @@ +#include +#include +#include +#include +#include + +#define TYPE_NS_ID \ + MIE_ID(0xe4, 0x99, 0x42, 0x58, 0x2b, 0xdb, 0x45, 0xa3, 0xbd, 0x4b, \ + 0x17, 0xe3, 0xc4, 0xa9, 0xbc, 0x30) +#define OP_NS_ID \ + MIE_ID(0xb9, 0x97, 0xcf, 0xd3, 0x81, 0xd4, 0x45, 0x06, 0x9b, 0x44, \ + 0x05, 0x9f, 0xb4, 0x76, 0xf1, 0x2d) + +struct mie_dialect *mie_dialect_create(struct mie_ctx *ctx, const char *name) +{ + struct mie_dialect *out = malloc(sizeof *out); + if (!out) { + return NULL; + } + + memset(out, 0x0, sizeof *out); + + out->d_name = b_strdup(name); + if (!out->d_name) { + free(out); + return NULL; + } + + mie_id op_ns = OP_NS_ID; + mie_id_map_init(&out->d_ops, &op_ns); + + mie_id type_ns = TYPE_NS_ID; + mie_id_map_init(&out->d_types, &type_ns); + + b_rope name_rope = B_ROPE_CSTR(name); + mie_id_map_put(&ctx->ctx_dialects, &out->d_id, &name_rope); + + return out; +} + +const struct mie_dialect_op *mie_dialect_get_op( + const struct mie_dialect *dialect, const char *name) +{ + b_rope name_rope = B_ROPE_CSTR(name); + mie_id id; + mie_id_init_ns(&id, mie_id_map_get_ns(&dialect->d_ops), &name_rope); + + mie_id *target = mie_id_map_get(&dialect->d_ops, &id); + return b_unbox(struct mie_dialect_op, target, op_id); +} + +const struct mie_dialect_type *mie_dialect_get_type( + const struct mie_dialect *dialect, const char *name) +{ + b_rope name_rope = B_ROPE_CSTR(name); + mie_id id; + mie_id_init_ns(&id, mie_id_map_get_ns(&dialect->d_types), &name_rope); + + mie_id *target = mie_id_map_get(&dialect->d_types, &id); + return b_unbox(struct mie_dialect_type, target, ty_id); +} diff --git a/mie/dialect/dialect.h b/mie/dialect/dialect.h new file mode 100644 index 0000000..e69de29 diff --git a/mie/dialect/func/func.c b/mie/dialect/func/func.c new file mode 100644 index 0000000..662e42b --- /dev/null +++ b/mie/dialect/func/func.c @@ -0,0 +1,22 @@ +#include +#include +#include + +static enum mie_status print(const struct mie_op *op, b_stream *out) +{ + return MIE_SUCCESS; +} + +static enum mie_status parse(struct mie_parser *parser, struct mie_op *out) +{ + return MIE_SUCCESS; +} + +MIE_DIALECT_OP_BEGIN(mie_func_func, "func") + MIE_DIALECT_OP_PRINT(print); + MIE_DIALECT_OP_PARSE(parse); +MIE_DIALECT_OP_END() + +MIE_DIALECT_BEGIN(mie_func, "func") + MIE_DIALECT_ADD_OP(mie_func_func); +MIE_DIALECT_END() diff --git a/mie/dialect/meta/meta.c b/mie/dialect/meta/meta.c new file mode 100644 index 0000000..b3cbd62 --- /dev/null +++ b/mie/dialect/meta/meta.c @@ -0,0 +1,6 @@ +#include +#include + +MIE_DIALECT_BEGIN(mie_meta, "meta") + MIE_DIALECT_ADD_OP(mie_meta_source_filename); +MIE_DIALECT_END() diff --git a/mie/dialect/meta/source-filename.c b/mie/dialect/meta/source-filename.c new file mode 100644 index 0000000..8729ee5 --- /dev/null +++ b/mie/dialect/meta/source-filename.c @@ -0,0 +1,18 @@ +#include +#include +#include + +static enum mie_status print(const struct mie_op *op, b_stream *out) +{ + return MIE_SUCCESS; +} + +static enum mie_status parse(struct mie_parser *parser, struct mie_op *out) +{ + return MIE_SUCCESS; +} + +MIE_DIALECT_OP_BEGIN(mie_meta_source_filename, "source-filename") + MIE_DIALECT_OP_PRINT(print); + MIE_DIALECT_OP_PARSE(parse); +MIE_DIALECT_OP_END() diff --git a/mie/dialect/op.c b/mie/dialect/op.c new file mode 100644 index 0000000..e670841 --- /dev/null +++ b/mie/dialect/op.c @@ -0,0 +1,25 @@ +#include +#include +#include + +struct mie_dialect_op *mie_dialect_op_create( + struct mie_dialect *parent, const char *name) +{ + struct mie_dialect_op *out = malloc(sizeof *out); + if (!out) { + return NULL; + } + + out->op_name = b_strdup(name); + if (!out->op_name) { + free(out); + return NULL; + } + + out->op_parent = parent; + + b_rope name_rope = B_ROPE_CSTR(name); + mie_id_map_put(&parent->d_ops, &out->op_id, &name_rope); + + return out; +} diff --git a/mie/dialect/ptr/load.c b/mie/dialect/ptr/load.c new file mode 100644 index 0000000..c2fd71f --- /dev/null +++ b/mie/dialect/ptr/load.c @@ -0,0 +1,18 @@ +#include +#include +#include + +static enum mie_status print(const struct mie_op *op, b_stream *out) +{ + return MIE_SUCCESS; +} + +static enum mie_status parse(struct mie_parser *parser, struct mie_op *out) +{ + return MIE_SUCCESS; +} + +MIE_DIALECT_OP_BEGIN(mie_ptr_load, "load") + MIE_DIALECT_OP_PRINT(print); + MIE_DIALECT_OP_PARSE(parse); +MIE_DIALECT_OP_END() diff --git a/mie/dialect/ptr/ptr.c b/mie/dialect/ptr/ptr.c new file mode 100644 index 0000000..3dad98e --- /dev/null +++ b/mie/dialect/ptr/ptr.c @@ -0,0 +1,32 @@ +#include +#include +#include + +struct ptr_type { + struct mie_dialect_type ptr_base; +}; + +static enum mie_status print( + const struct mie_dialect_type *def, const struct mie_type *ty, b_stream *out) +{ + return MIE_SUCCESS; +} + +static enum mie_status parse( + const struct mie_dialect_type *def, struct mie_parser *parser, + struct mie_type **out) +{ + return MIE_SUCCESS; +} + +MIE_DIALECT_TYPE_BEGIN(mie_ptr_ptr, "ptr") + MIE_DIALECT_TYPE_STRUCT(struct ptr_type); + MIE_DIALECT_TYPE_PRINT(print); + MIE_DIALECT_TYPE_PARSE(parse); +MIE_DIALECT_TYPE_END() + +MIE_DIALECT_BEGIN(mie_ptr, "ptr") + MIE_DIALECT_ADD_OP(mie_ptr_load); + MIE_DIALECT_ADD_OP(mie_ptr_store); + MIE_DIALECT_ADD_TYPE(mie_ptr_ptr); +MIE_DIALECT_END() diff --git a/mie/dialect/ptr/store.c b/mie/dialect/ptr/store.c new file mode 100644 index 0000000..2e8a77a --- /dev/null +++ b/mie/dialect/ptr/store.c @@ -0,0 +1,18 @@ +#include +#include +#include + +static enum mie_status print(const struct mie_op *op, b_stream *out) +{ + return MIE_SUCCESS; +} + +static enum mie_status parse(struct mie_parser *parser, struct mie_op *out) +{ + return MIE_SUCCESS; +} + +MIE_DIALECT_OP_BEGIN(mie_ptr_store, "store") + MIE_DIALECT_OP_PRINT(print); + MIE_DIALECT_OP_PARSE(parse); +MIE_DIALECT_OP_END() diff --git a/mie/dialect/scf/for.c b/mie/dialect/scf/for.c new file mode 100644 index 0000000..d808c70 --- /dev/null +++ b/mie/dialect/scf/for.c @@ -0,0 +1,18 @@ +#include +#include +#include + +static enum mie_status print(const struct mie_op *op, b_stream *out) +{ + return MIE_SUCCESS; +} + +static enum mie_status parse(struct mie_parser *parser, struct mie_op *out) +{ + return MIE_SUCCESS; +} + +MIE_DIALECT_OP_BEGIN(mie_scf_for, "for") + MIE_DIALECT_OP_PRINT(print); + MIE_DIALECT_OP_PARSE(parse); +MIE_DIALECT_OP_END() diff --git a/mie/dialect/scf/if.c b/mie/dialect/scf/if.c new file mode 100644 index 0000000..36a1947 --- /dev/null +++ b/mie/dialect/scf/if.c @@ -0,0 +1,18 @@ +#include +#include +#include + +static enum mie_status print(const struct mie_op *op, b_stream *out) +{ + return MIE_SUCCESS; +} + +static enum mie_status parse(struct mie_parser *parser, struct mie_op *out) +{ + return MIE_SUCCESS; +} + +MIE_DIALECT_OP_BEGIN(mie_scf_if, "if") + MIE_DIALECT_OP_PRINT(print); + MIE_DIALECT_OP_PARSE(parse); +MIE_DIALECT_OP_END() diff --git a/mie/dialect/scf/scf.c b/mie/dialect/scf/scf.c new file mode 100644 index 0000000..c3bbf8f --- /dev/null +++ b/mie/dialect/scf/scf.c @@ -0,0 +1,10 @@ +#include "scf.h" + +#include +#include + +MIE_DIALECT_BEGIN(mie_scf, "scf") + MIE_DIALECT_ADD_OP(mie_scf_if); + MIE_DIALECT_ADD_OP(mie_scf_for); + MIE_DIALECT_ADD_OP(mie_scf_yield); +MIE_DIALECT_END() diff --git a/mie/dialect/scf/scf.h b/mie/dialect/scf/scf.h new file mode 100644 index 0000000..3b8267f --- /dev/null +++ b/mie/dialect/scf/scf.h @@ -0,0 +1,7 @@ +#ifndef MIE_DIALECT_SCF_H_ +#define MIE_DIALECT_SCF_H_ + +#include +#include + +#endif diff --git a/mie/dialect/scf/yield.c b/mie/dialect/scf/yield.c new file mode 100644 index 0000000..7371ac6 --- /dev/null +++ b/mie/dialect/scf/yield.c @@ -0,0 +1,18 @@ +#include +#include +#include + +static enum mie_status print(const struct mie_op *op, b_stream *out) +{ + return MIE_SUCCESS; +} + +static enum mie_status parse(struct mie_parser *parser, struct mie_op *out) +{ + return MIE_SUCCESS; +} + +MIE_DIALECT_OP_BEGIN(mie_scf_yield, "yield") + MIE_DIALECT_OP_PRINT(print); + MIE_DIALECT_OP_PARSE(parse); +MIE_DIALECT_OP_END() diff --git a/mie/dialect/type.c b/mie/dialect/type.c new file mode 100644 index 0000000..e4c8a9e --- /dev/null +++ b/mie/dialect/type.c @@ -0,0 +1,25 @@ +#include +#include +#include + +struct mie_dialect_type *mie_dialect_type_create( + struct mie_dialect *parent, const char *name) +{ + struct mie_dialect_type *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; + + b_rope name_rope = B_ROPE_CSTR(name); + mie_id_map_put(&parent->d_types, &out->ty_id, &name_rope); + + return out; +} diff --git a/mie/include/mie/dialect/arith.h b/mie/include/mie/dialect/arith.h new file mode 100644 index 0000000..f6bb54c --- /dev/null +++ b/mie/include/mie/dialect/arith.h @@ -0,0 +1,15 @@ +#ifndef MIE_DIALECT_ARITH_H_ +#define MIE_DIALECT_ARITH_H_ + +#include +#include + +struct mie_ctx; +struct mie_dialect; + +MIE_API struct mie_dialect *mie_arith_dialect_create(struct mie_ctx *ctx); + +MIE_API struct mie_type *mie_arith_int_get_type( + struct mie_ctx *ctx, size_t bit_width); + +#endif diff --git a/mie/include/mie/dialect/builtin.h b/mie/include/mie/dialect/builtin.h new file mode 100644 index 0000000..165b07a --- /dev/null +++ b/mie/include/mie/dialect/builtin.h @@ -0,0 +1,14 @@ +#ifndef MIE_DIALECT_BUILTIN_H_ +#define MIE_DIALECT_BUILTIN_H_ + +#include + +struct mie_dialect; + +struct mie_ctx; +struct mie_int_type; +struct mie_float_type; + +MIE_API struct mie_dialect *mie_builtin_dialect_create(struct mie_ctx *ctx); + +#endif diff --git a/mie/include/mie/dialect/cf.h b/mie/include/mie/dialect/cf.h new file mode 100644 index 0000000..f530182 --- /dev/null +++ b/mie/include/mie/dialect/cf.h @@ -0,0 +1,11 @@ +#ifndef MIE_DIALECT_CF_H_ +#define MIE_DIALECT_CF_H_ + +#include + +struct mie_ctx; +struct mie_dialect; + +MIE_API struct mie_dialect *mie_cf_dialect_create(struct mie_ctx *ctx); + +#endif diff --git a/mie/include/mie/dialect/dialect.h b/mie/include/mie/dialect/dialect.h new file mode 100644 index 0000000..147dfac --- /dev/null +++ b/mie/include/mie/dialect/dialect.h @@ -0,0 +1,31 @@ +#ifndef MIE_DIALECT_DIALECT_H_ +#define MIE_DIALECT_DIALECT_H_ + +#include +#include +#include +#include +#include + +struct mie_ctx; + +struct mie_dialect_op; +struct mie_dialect_type; + +struct mie_dialect { + mie_id d_id; + char *d_name; + + struct mie_id_map d_ops; + struct mie_id_map d_types; +}; + +MIE_API struct mie_dialect *mie_dialect_create( + struct mie_ctx *ctx, const char *name); + +MIE_API const struct mie_dialect_op *mie_dialect_get_op( + const struct mie_dialect *dialect, const char *name); +MIE_API const struct mie_dialect_type *mie_dialect_get_type( + const struct mie_dialect *dialect, const char *name); + +#endif diff --git a/mie/include/mie/dialect/func.h b/mie/include/mie/dialect/func.h new file mode 100644 index 0000000..3b537b5 --- /dev/null +++ b/mie/include/mie/dialect/func.h @@ -0,0 +1,11 @@ +#ifndef MIE_DIALECT_FUNC_H_ +#define MIE_DIALECT_FUNC_H_ + +#include + +struct mie_ctx; +struct mie_dialect; + +MIE_API struct mie_dialect *mie_func_dialect_create(struct mie_ctx *ctx); + +#endif diff --git a/mie/include/mie/dialect/meta.h b/mie/include/mie/dialect/meta.h new file mode 100644 index 0000000..f73b383 --- /dev/null +++ b/mie/include/mie/dialect/meta.h @@ -0,0 +1,11 @@ +#ifndef MIE_DIALECT_META_H_ +#define MIE_DIALECT_META_H_ + +#include + +struct mie_ctx; +struct mie_dialect; + +MIE_API struct mie_dialect *mie_meta_dialect_create(struct mie_ctx *ctx); + +#endif diff --git a/mie/include/mie/dialect/op.h b/mie/include/mie/dialect/op.h new file mode 100644 index 0000000..ccc02f5 --- /dev/null +++ b/mie/include/mie/dialect/op.h @@ -0,0 +1,25 @@ +#ifndef MIE_DIALECT_OP_H_ +#define MIE_DIALECT_OP_H_ + +#include +#include +#include +#include + +struct mie_op; +struct mie_parser; +struct mie_dialect; + +struct mie_dialect_op { + mie_id op_id; + struct mie_dialect *op_parent; + char *op_name; + + enum mie_status (*op_print)(const struct mie_op *, b_stream *); + enum mie_status (*op_parse)(struct mie_parser *, struct mie_op *); +}; + +MIE_API struct mie_dialect_op *mie_dialect_op_create( + struct mie_dialect *parent, const char *name); + +#endif diff --git a/mie/include/mie/dialect/ptr.h b/mie/include/mie/dialect/ptr.h new file mode 100644 index 0000000..8b26c6d --- /dev/null +++ b/mie/include/mie/dialect/ptr.h @@ -0,0 +1,11 @@ +#ifndef MIE_DIALECT_PTR_H_ +#define MIE_DIALECT_PTR_H_ + +#include + +struct mie_ctx; +struct mie_dialect; + +MIE_API struct mie_dialect *mie_ptr_dialect_create(struct mie_ctx *ctx); + +#endif diff --git a/mie/include/mie/dialect/scf.h b/mie/include/mie/dialect/scf.h new file mode 100644 index 0000000..22bc5fb --- /dev/null +++ b/mie/include/mie/dialect/scf.h @@ -0,0 +1,11 @@ +#ifndef MIE_DIALECT_SCF_H_ +#define MIE_DIALECT_SCF_H_ + +#include + +struct mie_ctx; +struct mie_dialect; + +MIE_API struct mie_dialect *mie_scf_dialect_create(struct mie_ctx *ctx); + +#endif diff --git a/mie/include/mie/dialect/type.h b/mie/include/mie/dialect/type.h new file mode 100644 index 0000000..780ff38 --- /dev/null +++ b/mie/include/mie/dialect/type.h @@ -0,0 +1,33 @@ +#ifndef MIE_DIALECT_TYPE_H_ +#define MIE_DIALECT_TYPE_H_ + +#include +#include +#include +#include + +struct mie_type; +struct mie_parser; +struct mie_dialect; + +struct mie_dialect_type { + mie_id ty_id; + struct mie_dialect *ty_parent; + char *ty_name; + + size_t ty_data_size; + + enum mie_status (*ty_print)( + const struct mie_dialect_type *, const struct mie_type *, + b_stream *); + enum mie_status (*ty_parse)( + const struct mie_dialect_type *, struct mie_parser *, + struct mie_type **); + void (*ty_init)(const struct mie_dialect_type *, struct mie_type *); + void (*ty_cleanup)(const struct mie_dialect_type *, struct mie_type *); +}; + +MIE_API struct mie_dialect_type *mie_dialect_type_create( + struct mie_dialect *parent, const char *name); + +#endif