From 6d8b0392bb0c0df82285eec1b0f692113e66eb1a Mon Sep 17 00:00:00 2001 From: hachem Date: Sat, 19 Sep 2026 15:47:03 +0200 Subject: feat: enable_if --- eval.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'eval.c') diff --git a/eval.c b/eval.c index cb967c2..3f27fa2 100644 --- a/eval.c +++ b/eval.c @@ -254,6 +254,18 @@ static enum RunStatus emit(struct Machine* machine, const struct Node* node) return RUN_DONE; } +static enum RunStatus enable_if(struct Machine* machine, const struct Node* node) +{ + bool truth = false; + if (evaluate_condition(machine, node->first, &truth)) + return RUN_FAILED; + + if (!truth) + return RUN_DONE; + + return execute(machine, node->body); +} + static enum RunStatus static_assert_statement(struct Machine* machine, const struct Node* node) { bool truth = false; @@ -275,6 +287,7 @@ static enum RunStatus execute_one(struct Machine* machine, const struct Node* no { case STMT_DECLARE: return declare(machine, node); case STMT_UNDECLARE: return undeclare(machine, node); + case STMT_ENABLE_IF: return enable_if(machine, node); case STMT_EMIT: return emit(machine, node); case STMT_STATIC_ASSERT: return static_assert_statement(machine, node); default: break; -- cgit v1.3