diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-07-20 15:17:04 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-07-20 15:17:04 +0100 |
| commit | 6d37ed12d2e9914bd308dbf2fd3dec166cc78af1 (patch) | |
| tree | 50597ee875a84c1ec2f8c64d031cb9857c0c233f /src/ssa.cpp | |
| parent | eab23cd5b74b9df2f5158138510b45c83bbf1bc8 (diff) | |
Update internals of a Union and Tuple
Diffstat (limited to 'src/ssa.cpp')
| -rw-r--r-- | src/ssa.cpp | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/ssa.cpp b/src/ssa.cpp index a1b5c3827..ef9b03dce 100644 --- a/src/ssa.cpp +++ b/src/ssa.cpp @@ -639,10 +639,10 @@ bool can_ssa_type(Type *t) { case Type_Map: return false; case Type_Tuple: - if (t->Tuple.variable_count > SSA_MAX_STRUCT_FIELD_COUNT) { + if (t->Tuple.variables.count > SSA_MAX_STRUCT_FIELD_COUNT) { return false; } - for (isize i = 0; i < t->Tuple.variable_count; i++) { + for_array(i, t->Tuple.variables) { if (!can_ssa_type(t->Tuple.variables[i]->type)) { return false; } @@ -813,14 +813,9 @@ ssaValue *ssa_emit_ptr_index(ssaProc *p, ssaValue *s, i64 index) { GB_ASSERT(t->Record.field_count > 0); GB_ASSERT(gb_is_between(index, 0, t->Record.field_count-1)); result_type = make_type_pointer(a, t->Record.fields[index]->type); - } else if (is_type_union(t)) { - type_set_offsets(a, t); - GB_ASSERT(t->Record.field_count > 0); - GB_ASSERT(gb_is_between(index, 0, t->Record.field_count-1)); - result_type = make_type_pointer(a, t->Record.fields[index]->type); } else if (is_type_tuple(t)) { - GB_ASSERT(t->Tuple.variable_count > 0); - GB_ASSERT(gb_is_between(index, 0, t->Tuple.variable_count-1)); + GB_ASSERT(t->Tuple.variables.count > 0); + GB_ASSERT(gb_is_between(index, 0, t->Tuple.variables.count-1)); result_type = make_type_pointer(a, t->Tuple.variables[index]->type); } else if (is_type_slice(t)) { switch (index) { @@ -882,8 +877,7 @@ ssaValue *ssa_emit_value_index(ssaProc *p, ssaValue *s, i64 index) { GB_ASSERT(gb_is_between(index, 0, t->Record.field_count-1)); result_type = t->Record.fields[index]->type; } else if (is_type_tuple(t)) { - GB_ASSERT(t->Tuple.variable_count > 0); - GB_ASSERT(gb_is_between(index, 0, t->Tuple.variable_count-1)); + GB_ASSERT(t->Tuple.variables.count > 0); result_type = t->Tuple.variables[index]->type; } else if (is_type_slice(t)) { switch (index) { @@ -2015,7 +2009,7 @@ void ssa_build_stmt_internal(ssaProc *p, AstNode *node) { Type *t = base_type(init->type); // TODO(bill): refactor for code reuse as this is repeated a bit if (t->kind == Type_Tuple) { - for (isize i = 0; i < t->Tuple.variable_count; i++) { + for_array(i, t->Tuple.variables) { Entity *e = t->Tuple.variables[i]; ssaValue *v = ssa_emit_value_index(p, init, i); array_add(&inits, v); |