diff options
| author | gingerBill <bill@gingerbill.org> | 2023-07-24 15:46:54 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2023-07-24 15:46:54 +0100 |
| commit | 78116e0ea24aef3f663832edfb5f9cd6aa7b6e57 (patch) | |
| tree | 1ab8ad92d8c9d93ba506892333ca91e3d55edba1 /src/tilde_expr.cpp | |
| parent | 5a50afa1fd863caa5459f516b2d6a482611cd4c7 (diff) | |
Implement for in statements for array-like values
Diffstat (limited to 'src/tilde_expr.cpp')
| -rw-r--r-- | src/tilde_expr.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/tilde_expr.cpp b/src/tilde_expr.cpp index 07e60f1a6..993270c14 100644 --- a/src/tilde_expr.cpp +++ b/src/tilde_expr.cpp @@ -2417,22 +2417,20 @@ cgAddr cg_build_addr_compound_lit(cgProcedure *p, Ast *expr) { // break; // } - // case Type_Array: { - // cg_addr_store(p, v, cg_const_value(p->module, type, exact_value_compound(expr))); - - // auto temp_data = array_make<cgCompoundLitElemTempData>(temporary_allocator(), 0, cl->elems.count); + case Type_Array: { + auto temp_data = array_make<cgCompoundLitElemTempData>(temporary_allocator(), 0, cl->elems.count); - // populate(p, cl->elems, &temp_data, type); + populate(p, cl->elems, &temp_data, type); - // cgValue dst_ptr = cg_addr_get_ptr(p, v); - // for_array(i, temp_data) { - // i32 index = cast(i32)(temp_data[i].elem_index); - // temp_data[i].gep = cg_emit_array_epi(p, dst_ptr, index); - // } + cgValue dst_ptr = cg_addr_get_ptr(p, v); + for_array(i, temp_data) { + i32 index = cast(i32)(temp_data[i].elem_index); + temp_data[i].gep = cg_emit_array_epi(p, dst_ptr, index); + } - // assign_array(p, temp_data); - // break; - // } + assign_array(p, temp_data); + break; + } // case Type_EnumeratedArray: { // cg_addr_store(p, v, cg_const_value(p->module, type, exact_value_compound(expr))); @@ -2468,7 +2466,7 @@ cgAddr cg_build_addr_compound_lit(cgProcedure *p, Ast *expr) { } assign_array(p, temp_data); - cg_fill_slice(p, v, data, cg_const_int(p, t_int, cl->max_count)); + cg_fill_slice(p, v, data, cg_const_int(p, t_int, count)); return v; } |