aboutsummaryrefslogtreecommitdiff
path: root/src/ssa.cpp
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2017-07-20 15:32:34 +0100
committerGinger Bill <bill@gingerbill.org>2017-07-20 15:32:34 +0100
commit13bc6eeea4cc89b06bcfc3aaef7bfb85c1cb5b01 (patch)
tree1d359e2f6b6f72c2f37b4262955e932718dfe312 /src/ssa.cpp
parent2da18b6d3323454d2c820dac8d17875f8b48f914 (diff)
Make `fields` et al an Array rather than a raw pointer
Diffstat (limited to 'src/ssa.cpp')
-rw-r--r--src/ssa.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/ssa.cpp b/src/ssa.cpp
index 1ba1f610d..d934bb644 100644
--- a/src/ssa.cpp
+++ b/src/ssa.cpp
@@ -653,10 +653,10 @@ bool can_ssa_type(Type *t) {
case Type_Struct:
if (!t->Struct.is_raw_union) {
- if (t->Struct.field_count > SSA_MAX_STRUCT_FIELD_COUNT) {
+ if (t->Struct.fields.count > SSA_MAX_STRUCT_FIELD_COUNT) {
return false;
}
- for (isize i = 0; i < t->Struct.field_count; i++) {
+ for_array(i, t->Struct.fields) {
if (!can_ssa_type(t->Struct.fields[i]->type)) {
return false;
}
@@ -810,8 +810,7 @@ ssaValue *ssa_emit_ptr_index(ssaProc *p, ssaValue *s, i64 index) {
Type *result_type = nullptr;
if (is_type_struct(t)) {
- GB_ASSERT(t->Struct.field_count > 0);
- GB_ASSERT(gb_is_between(index, 0, t->Struct.field_count-1));
+ GB_ASSERT(t->Struct.fields.count > 0);
result_type = make_type_pointer(a, t->Struct.fields[index]->type);
} else if (is_type_tuple(t)) {
GB_ASSERT(t->Tuple.variables.count > 0);
@@ -868,13 +867,11 @@ ssaValue *ssa_emit_value_index(ssaProc *p, ssaValue *s, i64 index) {
Type *result_type = nullptr;
if (is_type_struct(t)) {
- GB_ASSERT(t->Struct.field_count > 0);
- GB_ASSERT(gb_is_between(index, 0, t->Struct.field_count-1));
+ GB_ASSERT(t->Struct.fields.count > 0);
result_type = t->Struct.fields[index]->type;
} else if (is_type_union(t)) {
type_set_offsets(a, t);
- GB_ASSERT(t->Struct.field_count > 0);
- GB_ASSERT(gb_is_between(index, 0, t->Struct.field_count-1));
+ GB_ASSERT(t->Struct.fields.count > 0);
result_type = t->Struct.fields[index]->type;
} else if (is_type_tuple(t)) {
GB_ASSERT(t->Tuple.variables.count > 0);
@@ -1658,7 +1655,7 @@ ssaValue *ssa_build_expr(ssaProc *p, AstNode *expr) {
default: GB_PANIC("Unknown float size");
}
}
- // IMPORTANT TODO(bill): Do constant struct/array literals correctly
+ // IMPORTANT TODO(bill): Do constant str/array literals correctly
return ssa_const_nil(p, tv.type);
}