Fix expand_to_tuple

This commit is contained in:
Ginger Bill
2017-06-27 22:47:19 +01:00
parent 5df854fcef
commit 647e2cafd7
2 changed files with 6 additions and 4 deletions
+1 -1
View File
@@ -4609,7 +4609,7 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
tuple->Tuple.variable_count = variable_count;
// TODO(bill): Should I copy each of the entities or is this good enough?
gb_memcopy_array(tuple->Tuple.variables, type->Record.fields, variable_count);
gb_memcopy_array(tuple->Tuple.variables, type->Record.fields_in_src_order, variable_count);
operand->type = tuple;
operand->mode = Addressing_Value;
+5 -3
View File
@@ -4316,9 +4316,11 @@ irValue *ir_build_builtin_proc(irProcedure *proc, AstNode *expr, TypeAndValue tv
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);
for (isize src_index = 0; src_index < t->Record.field_count; src_index++) {
Entity *field = t->Record.fields_in_src_order[src_index];
i32 field_index = field->Variable.field_index;
irValue *f = ir_emit_struct_ev(proc, s, field_index);
irValue *ep = ir_emit_struct_ep(proc, tuple, src_index);
ir_emit_store(proc, ep, f);
}
return ir_emit_load(proc, tuple);