diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-03-30 13:24:39 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-03-30 13:24:39 -0400 |
| commit | e5880b46165f0756f8d5589626ea936271df2732 (patch) | |
| tree | f87b2807b8e656a022827ab9bdd36b87c631feed | |
| parent | 42084fda6f0f45f2b13aa2867bd26acf4ef9eae2 (diff) | |
REPL 'if'
| -rw-r--r-- | repl.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -326,7 +326,6 @@ void run(env_t *env, ast_t *ast) } // UpdateAssign, // FunctionDef, - // Block, // For, While, If, When, // Skip, Stop, Pass, // Return, @@ -336,6 +335,19 @@ void run(env_t *env, ast_t *ast) // Use, // LinkerDirective, // InlineCCode, + case If: { + auto if_ = Match(ast, If); + bool condition; + type_t *cond_t = get_type(env, if_->condition); + assert(cond_t->tag == BoolType); + eval(env, if_->condition, &condition); + if (condition) { + run(env, if_->body); + } else if (if_->else_body) { + run(env, if_->else_body); + } + break; + } default: { eval(env, ast, NULL); break; |
