aboutsummaryrefslogtreecommitdiff
path: root/environment.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-08-10 15:15:38 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-08-10 15:15:38 -0400
commit8d3d5913129a8ede381462d5ad5e98f9c789e5c8 (patch)
tree074e1fd4489710af0810e2a901106a7161467021 /environment.c
parentcb6cebf12e2124503f0551bc1bf6b44f68d86746 (diff)
Add Sets to the language
Diffstat (limited to 'environment.c')
-rw-r--r--environment.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/environment.c b/environment.c
index 69ad9b66..84f6880e 100644
--- a/environment.c
+++ b/environment.c
@@ -333,6 +333,16 @@ env_t *for_scope(env_t *env, ast_t *ast)
}
return scope;
}
+ case SetType: {
+ if (for_->vars) {
+ if (for_->vars->next)
+ code_err(for_->vars->next->ast, "This is too many variables for this loop");
+ type_t *item_type = Match(iter_t, SetType)->item_type;
+ const char *name = Match(for_->vars->ast, Var)->name;
+ set_binding(scope, name, new(binding_t, .type=item_type, .code=CORD_cat("$", name)));
+ }
+ return scope;
+ }
case TableType: {
const char *vars[2] = {};
int64_t num_vars = 0;