diff --git a/mie/ctx.c b/mie/ctx.c index 989b1d8..69689c3 100644 --- a/mie/ctx.c +++ b/mie/ctx.c @@ -70,6 +70,27 @@ struct mie_ctx *mie_ctx_create(void) return out; } +struct mie_op *mie_ctx_create_op( + const struct mie_ctx *ctx, const char *dialect, const char *op) +{ + const struct mie_op_definition *def + = mie_ctx_get_op_definition(ctx, dialect, op); + if (!def) { + return NULL; + } + + struct mie_op *out = mie_op_create(); + if (!out) { + return NULL; + } + + out->op_flags |= MIE_OP_F_OP_RESOLVED; + out->op_info = def; + out->op_dialect = def->op_parent; + + return out; +} + bool mie_ctx_resolve_op(const struct mie_ctx *ctx, struct mie_op *op) { if (op->op_flags & MIE_OP_F_OP_RESOLVED) { diff --git a/mie/include/mie/ctx.h b/mie/include/mie/ctx.h index 0a3ecdc..e53290e 100644 --- a/mie/include/mie/ctx.h +++ b/mie/include/mie/ctx.h @@ -36,6 +36,8 @@ struct mie_ctx { MIE_API struct mie_ctx *mie_ctx_create(void); MIE_API void mie_ctx_destroy(struct mie_ctx *ctx); +MIE_API struct mie_op *mie_ctx_create_op( + const struct mie_ctx *ctx, const char *dialect, const char *op); MIE_API bool mie_ctx_resolve_op(const struct mie_ctx *ctx, struct mie_op *op); MIE_API struct mie_dialect *mie_ctx_get_dialect(