aboutsummaryrefslogtreecommitdiff
path: root/src/types.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2023-07-25 15:15:35 +0100
committergingerBill <bill@gingerbill.org>2023-07-25 15:15:35 +0100
commit0f217c715ecd9fc265b1c6a3d579b99ecf849139 (patch)
treeaf3a2b1847c5066e89d7c11365c45945800b464d /src/types.cpp
parentc4033c215e01343709a0d7928c277a6425f53524 (diff)
Fix dependency issue; Allow polymorphic procedures in tilde
Diffstat (limited to 'src/types.cpp')
-rw-r--r--src/types.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/types.cpp b/src/types.cpp
index 17945b109..f6e377cdc 100644
--- a/src/types.cpp
+++ b/src/types.cpp
@@ -3646,18 +3646,26 @@ gb_internal i64 *type_set_offsets_of(Slice<Entity *> const &fields, bool is_pack
}
} else if (is_packed) {
for_array(i, fields) {
- i64 size = type_size_of(fields[i]->type);
- offsets[i] = curr_offset;
- curr_offset += size;
+ if (fields[i]->kind != Entity_Variable) {
+ offsets[i] = -1;
+ } else {
+ i64 size = type_size_of(fields[i]->type);
+ offsets[i] = curr_offset;
+ curr_offset += size;
+ }
}
} else {
for_array(i, fields) {
- Type *t = fields[i]->type;
- i64 align = gb_max(type_align_of(t), 1);
- i64 size = gb_max(type_size_of( t), 0);
- curr_offset = align_formula(curr_offset, align);
- offsets[i] = curr_offset;
- curr_offset += size;
+ if (fields[i]->kind != Entity_Variable) {
+ offsets[i] = -1;
+ } else {
+ Type *t = fields[i]->type;
+ i64 align = gb_max(type_align_of(t), 1);
+ i64 size = gb_max(type_size_of( t), 0);
+ curr_offset = align_formula(curr_offset, align);
+ offsets[i] = curr_offset;
+ curr_offset += size;
+ }
}
}
return offsets;
@@ -3924,7 +3932,9 @@ gb_internal i64 type_offset_of(Type *t, i64 index, Type **field_type_) {
if (gb_is_between(index, 0, t->Tuple.variables.count-1)) {
GB_ASSERT(t->Tuple.offsets != nullptr);
if (field_type_) *field_type_ = t->Tuple.variables[index]->type;
- return t->Tuple.offsets[index];
+ i64 offset = t->Tuple.offsets[index];
+ GB_ASSERT(offset >= 0);
+ return offset;
}
break;