mie: func: add function-like trait
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <mie/macros.h>
|
||||
|
||||
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_return);
|
||||
MIE_DIALECT_END()
|
||||
|
||||
@@ -130,6 +130,7 @@ MIE_OP_DEFINITION_BEGIN(mie_func_func, "func")
|
||||
MIE_OP_DEFINITION_PRINT(print);
|
||||
MIE_OP_DEFINITION_PARSE(parse);
|
||||
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_FUNC(sym_get_name) = NULL;
|
||||
MIE_OP_INTERFACE_END()
|
||||
|
||||
23
mie/dialect/func/trait/function-like.c
Normal file
23
mie/dialect/func/trait/function-like.c
Normal 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()
|
||||
Reference in New Issue
Block a user