diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-06-24 20:39:37 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-06-24 20:39:37 +0100 |
| commit | 18f885efabb98fb91ab0c6e9586a8b66eab511d9 (patch) | |
| tree | 2696456aa1a28d946f7d7585dbff52ac38cf9707 /src/ir.cpp | |
| parent | bba088bee70a220c6ff99fc7fe68245e1ad6f932 (diff) | |
`expand_to_tuple`
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index b2a6b9579..cd611ea44 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -4283,6 +4283,23 @@ irValue *ir_build_builtin_proc(irProcedure *proc, AstNode *expr, TypeAndValue tv return ir_emit_load(proc, slice); } break; + case BuiltinProc_expand_to_tuple: { + ir_emit_comment(proc, str_lit("expand_to_tuple")); + irValue *s = ir_build_expr(proc, ce->args[0]); + Type *t = base_type(ir_type(s)); + + GB_ASSERT(t->kind == Type_Record); + GB_ASSERT(is_type_tuple(tv.type)); + + irValue *tuple = ir_add_local_generated(proc, tv.type); + for (isize i = 0; i < t->Record.field_count; i++) { + irValue *f = ir_emit_struct_ev(proc, s, i); + irValue *ep = ir_emit_struct_ep(proc, tuple, i); + ir_emit_store(proc, ep, f); + } + return ir_emit_load(proc, tuple); + } break; + case BuiltinProc_min: { ir_emit_comment(proc, str_lit("min")); Type *t = type_of_expr(proc->module->info, expr); |