diff options
Diffstat (limited to 'eval.c')
| -rw-r--r-- | eval.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -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; |
