diff options
| author | gingerBill <bill@gingerbill.org> | 2023-07-18 13:27:47 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2023-07-18 13:27:47 +0100 |
| commit | c6593e8cdee3bbe3057be7a4728db3293265b663 (patch) | |
| tree | 4f0e578a46b93bb6193df4779e40922c4e2345ad /src/tilde_stmt.cpp | |
| parent | 4d8d3919c0cf0610e523c8bd13f8ffeaef56d1e4 (diff) | |
Mock out binary expressions and variable declarations
Diffstat (limited to 'src/tilde_stmt.cpp')
| -rw-r--r-- | src/tilde_stmt.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/tilde_stmt.cpp b/src/tilde_stmt.cpp index 6680277ed..cc15c2abc 100644 --- a/src/tilde_stmt.cpp +++ b/src/tilde_stmt.cpp @@ -966,13 +966,32 @@ gb_internal void cg_build_stmt(cgProcedure *p, Ast *node) { for (Ast *name : vd->names) { if (!is_blank_ident(name)) { Entity *e = entity_of_node(name); - bool zero_init = true; - cgAddr addr = cg_add_local(p, e->type, e, zero_init); + cgAddr addr = cg_add_local(p, e->type, e, true); gb_unused(addr); } } } else { - GB_PANIC("TODO multiple variables"); + auto lvals = slice_make<cgAddr>(temporary_allocator(), vd->names.count); + auto inits = array_make<cgValue>(temporary_allocator(), 0, lvals.count); + for (Ast *rhs : values) { + rhs = unparen_expr(rhs); + cgValue init = cg_build_expr(p, rhs); + cg_append_tuple_values(p, &inits, init); + } + + for_array(i, vd->names) { + Ast *name = vd->names[i]; + if (!is_blank_ident(name)) { + Entity *e = entity_of_node(name); + lvals[i] = cg_add_local(p, e->type, e, true); + } + } + GB_ASSERT(lvals.count == inits.count); + for_array(i, inits) { + cgAddr lval = lvals[i]; + cgValue init = inits[i]; + cg_addr_store(p, lval, init); + } } case_end; |