aboutsummaryrefslogtreecommitdiff
path: root/src/llvm_backend_stmt.cpp
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2026-02-17 11:11:56 +0000
committerGitHub <noreply@github.com>2026-02-17 11:11:56 +0000
commita7ed7ccd0c392cfbb6cb2e486fc7c75b16791902 (patch)
tree8a325415e65ad09cf81547b957753b99d867aaf9 /src/llvm_backend_stmt.cpp
parentbfe1f234ec763fc79359f7614ae4cccab88780e7 (diff)
parent58deab46a3e2423789f2af5e6ec7a4ef69ce810e (diff)
Merge pull request #6259 from odin-lang/bill/range-init
`for init; x in y {}` style loops (proof of concept)
Diffstat (limited to 'src/llvm_backend_stmt.cpp')
-rw-r--r--src/llvm_backend_stmt.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/llvm_backend_stmt.cpp b/src/llvm_backend_stmt.cpp
index 05ec10cda..98b45f646 100644
--- a/src/llvm_backend_stmt.cpp
+++ b/src/llvm_backend_stmt.cpp
@@ -756,6 +756,10 @@ gb_internal void lb_build_range_interval(lbProcedure *p, AstBinaryExpr *node,
lb_open_scope(p, scope);
+ if (rs->init != nullptr) {
+ lb_build_stmt(p, rs->init);
+ }
+
Ast *val0 = rs->vals.count > 0 ? lb_strip_and_prefix(rs->vals[0]) : nullptr;
Ast *val1 = rs->vals.count > 1 ? lb_strip_and_prefix(rs->vals[1]) : nullptr;
Type *val0_type = nullptr;
@@ -948,6 +952,10 @@ gb_internal void lb_build_range_tuple(lbProcedure *p, AstRangeStmt *rs, Scope *s
lb_open_scope(p, scope);
+ if (rs->init != nullptr) {
+ lb_build_stmt(p, rs->init);
+ }
+
lbBlock *loop = lb_create_block(p, "for.tuple.loop");
lb_emit_jump(p, loop);
lb_start_block(p, loop);
@@ -1002,6 +1010,9 @@ gb_internal void lb_build_range_stmt_struct_soa(lbProcedure *p, AstRangeStmt *rs
lb_open_scope(p, scope);
+ if (rs->init != nullptr) {
+ lb_build_stmt(p, rs->init);
+ }
Ast *val0 = rs->vals.count > 0 ? lb_strip_and_prefix(rs->vals[0]) : nullptr;
Ast *val1 = rs->vals.count > 1 ? lb_strip_and_prefix(rs->vals[1]) : nullptr;
@@ -1153,6 +1164,10 @@ gb_internal void lb_build_range_stmt(lbProcedure *p, AstRangeStmt *rs, Scope *sc
lb_open_scope(p, scope);
+ if (rs->init != nullptr) {
+ lb_build_stmt(p, rs->init);
+ }
+
Ast *val0 = rs->vals.count > 0 ? lb_strip_and_prefix(rs->vals[0]) : nullptr;
Ast *val1 = rs->vals.count > 1 ? lb_strip_and_prefix(rs->vals[1]) : nullptr;
Type *val0_type = nullptr;
@@ -1352,6 +1367,10 @@ gb_internal void lb_build_unroll_range_stmt(lbProcedure *p, AstUnrollRangeStmt *
lb_open_scope(p, scope); // Open scope here
+ if (rs->init != nullptr) {
+ lb_build_stmt(p, rs->init);
+ }
+
Ast *val0 = lb_strip_and_prefix(rs->val0);
Ast *val1 = lb_strip_and_prefix(rs->val1);
Type *val0_type = nullptr;