mie: func: add function-like trait

This commit is contained in:
2026-01-31 23:29:17 +00:00
parent 3f901ed83a
commit f37ee90b0e
3 changed files with 25 additions and 0 deletions

View File

@@ -3,6 +3,7 @@
#include <mie/macros.h> #include <mie/macros.h>
MIE_DIALECT_BEGIN(mie_func, struct mie_dialect, "func") MIE_DIALECT_BEGIN(mie_func, struct mie_dialect, "func")
MIE_DIALECT_ADD_TRAIT(mie_func_function_like);
MIE_DIALECT_ADD_OP(mie_func_func); MIE_DIALECT_ADD_OP(mie_func_func);
MIE_DIALECT_ADD_OP(mie_func_return); MIE_DIALECT_ADD_OP(mie_func_return);
MIE_DIALECT_END() MIE_DIALECT_END()

View File

@@ -130,6 +130,7 @@ MIE_OP_DEFINITION_BEGIN(mie_func_func, "func")
MIE_OP_DEFINITION_PRINT(print); MIE_OP_DEFINITION_PRINT(print);
MIE_OP_DEFINITION_PARSE(parse); MIE_OP_DEFINITION_PARSE(parse);
MIE_OP_DEFINITION_TRAIT("builtin", "isolated-from-above"); MIE_OP_DEFINITION_TRAIT("builtin", "isolated-from-above");
MIE_OP_DEFINITION_TRAIT("func", "function-like");
MIE_OP_INTERFACE_BEGIN("builtin", "symbol", struct mie_symbol) MIE_OP_INTERFACE_BEGIN("builtin", "symbol", struct mie_symbol)
MIE_OP_INTERFACE_FUNC(sym_get_name) = NULL; MIE_OP_INTERFACE_FUNC(sym_get_name) = NULL;
MIE_OP_INTERFACE_END() MIE_OP_INTERFACE_END()

View File

@@ -0,0 +1,23 @@
#include <mie/dialect/dialect.h>
#include <mie/macros.h>
#include <mie/trait/trait-definition.h>
#include <mie/trait/trait.h>
static enum mie_status validate(
const struct mie_trait_definition *trait_def,
const struct mie_trait *trait, const struct mie_trait_target *target)
{
return MIE_SUCCESS;
}
/* func.function-like trait:
* the op behaves like a func.func. this means that it:
* a) has a single region
* b) that region has one or more blocks representing the body of a function.
* c) the op has sym_name, function_type, and other function-related attributes.
*/
MIE_TRAIT_DEFINITION_BEGIN(mie_func_function_like, "function-like")
MIE_TRAIT_DEFINITION_TARGETS(MIE_TRAIT_TARGET_OP);
MIE_TRAIT_DEFINITION_STRUCT(struct mie_trait);
MIE_TRAIT_DEFINITION_VALIDATE(validate);
MIE_TRAIT_DEFINITION_END()