mie: ir: op: add functions to query a certain trait or interface
This commit is contained in:
@@ -72,6 +72,11 @@ MIE_API void mie_op_destroy(struct mie_op *op);
|
|||||||
MIE_API void mie_op_init(struct mie_op *op);
|
MIE_API void mie_op_init(struct mie_op *op);
|
||||||
MIE_API void mie_op_cleanup(struct mie_op *op);
|
MIE_API void mie_op_cleanup(struct mie_op *op);
|
||||||
|
|
||||||
|
MIE_API bool mie_op_has_trait(
|
||||||
|
const struct mie_op *op, const char *dialect_name, const char *trait_name);
|
||||||
|
MIE_API bool mie_op_has_interface(
|
||||||
|
const struct mie_op *op, const char *dialect_name, const char *iface_name);
|
||||||
|
|
||||||
MIE_API const struct mie_type *mie_op_arg_get_type(const struct mie_op_arg *arg);
|
MIE_API const struct mie_type *mie_op_arg_get_type(const struct mie_op_arg *arg);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
32
mie/ir/op.c
32
mie/ir/op.c
@@ -1,3 +1,4 @@
|
|||||||
|
#include <mie/ir/op-definition.h>
|
||||||
#include <mie/ir/op.h>
|
#include <mie/ir/op.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
@@ -30,3 +31,34 @@ void mie_op_cleanup(struct mie_op *op)
|
|||||||
{
|
{
|
||||||
/* TODO */
|
/* TODO */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool mie_op_has_trait(
|
||||||
|
const struct mie_op *op, const char *dialect_name, const char *trait_name)
|
||||||
|
{
|
||||||
|
if (!op->op_info) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mie_trait_table_get_unique(
|
||||||
|
&op->op_info->op_traits, dialect_name, trait_name)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct mie_trait_table_iterator it;
|
||||||
|
enum mie_status status = mie_trait_table_get_generic(
|
||||||
|
&op->op_info->op_traits, dialect_name, trait_name, &it);
|
||||||
|
|
||||||
|
return (status == MIE_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool mie_op_has_interface(
|
||||||
|
const struct mie_op *op, const char *dialect_name, const char *iface_name)
|
||||||
|
{
|
||||||
|
if (!op->op_info) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const struct mie_interface *p = mie_interface_map_get(
|
||||||
|
&op->op_info->op_iface, dialect_name, iface_name);
|
||||||
|
return p != NULL;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user