aboutsummaryrefslogtreecommitdiff
path: root/repl.c
diff options
context:
space:
mode:
Diffstat (limited to 'repl.c')
-rw-r--r--repl.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/repl.c b/repl.c
index b289ff39..815b1cdb 100644
--- a/repl.c
+++ b/repl.c
@@ -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;