mie: add data structures to represent type-instances

unlike values, type-instances represent specialisations of parametised types.
they behave like concrete implementations of C++ template types.

for example: arith.int represents an integer type of unspecified bit-width.
a type-instance of this type would be arith.int<32> (or i32 for short) which
has a defined width of 32 bits.
This commit is contained in:
2026-01-04 14:10:52 +00:00
parent 7b6ce3bf6e
commit add09d4958
3 changed files with 68 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
#ifndef MIE_TYPE_FUNCTION_H_
#define MIE_TYPE_FUNCTION_H_
#include <mie/type/type.h>
#include <mie/vector.h>
struct mie_function_type {
struct mie_type func_base;
MIE_VECTOR_DECLARE(struct mie_type *, func_in);
MIE_VECTOR_DECLARE(struct mie_type *, func_out);
};
MIE_API struct mie_function_type *mie_function_type_create(void);
MIE_API void mie_function_type_add_in_part(
struct mie_function_type *ty, struct mie_type *part);
MIE_API void mie_function_type_add_out_part(
struct mie_function_type *ty, struct mie_type *part);
#endif

View File

@@ -0,0 +1,17 @@
#ifndef MIE_TYPE_STORAGE_H_
#define MIE_TYPE_STORAGE_H_
#include <mie/type/type.h>
#include <mie/vector.h>
struct mie_storage_type {
struct mie_type st_base;
MIE_VECTOR_DECLARE(struct mie_type *, st_parts);
};
MIE_API struct mie_storage_type *mie_storage_type_create(void);
MIE_API void mie_storage_type_add_part(
struct mie_storage_type *ty, struct mie_type *part);
#endif

View File

@@ -0,0 +1,31 @@
#ifndef MIE_TYPE_TYPE_H_
#define MIE_TYPE_TYPE_H_
#include <mie/id.h>
#include <mie/misc.h>
#include <stddef.h>
struct mie_dialect;
struct mie_dialect_type;
struct mie_type;
/* a mie_type is an instance of mie_dialect_type.
* if the mie_dialect_type is a parametised type, the resulting mie_type
* will have those parameters baked in.
* this is a base struct. dialects that defined their own types do so by
* inheriting from this struct. */
struct mie_type {
/* this is NOT the same as ty_def->ty_id */
mie_id ty_id;
/* this pointer is optional. if it is NULL, the name of the type can
* be found in ty_def */
char *ty_name;
struct mie_dialect_type *ty_def;
};
MIE_API struct mie_type *mie_type_create(struct mie_dialect_type *type);
#endif