aboutsummaryrefslogtreecommitdiff
path: root/src/types.cpp
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2017-07-29 13:01:17 +0100
committerGinger Bill <bill@gingerbill.org>2017-07-29 13:01:17 +0100
commit24c812115e8cbc905b1a5c1d73182da5db94dfde (patch)
tree7b22566bc3c85ba91f478e416a6f9063ec3b8188 /src/types.cpp
parent1df4aa90ce10dca629b8af73e74f884ab2339096 (diff)
Remove empty union check on array types; Fix overflowing error printing
Diffstat (limited to 'src/types.cpp')
-rw-r--r--src/types.cpp36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/types.cpp b/src/types.cpp
index 13480eb3f..becb4cf06 100644
--- a/src/types.cpp
+++ b/src/types.cpp
@@ -150,12 +150,12 @@ struct TypeStruct {
ProcCallingConvention calling_convention; \
}) \
TYPE_KIND(Map, struct { \
- i64 count; /* 0 if dynamic */ \
- Type *key; \
- Type *value; \
- Type *entry_type; \
- Type *generated_struct_type; \
- Type *lookup_result_type; \
+ i64 count; /* 0 if dynamic */ \
+ Type * key; \
+ Type * value; \
+ Type * entry_type; \
+ Type * generated_struct_type; \
+ Type * lookup_result_type; \
}) \
TYPE_KIND(BitFieldValue, struct { u32 bits; }) \
TYPE_KIND(BitField, struct { \
@@ -386,10 +386,11 @@ gb_global Type *t_map_header = nullptr;
-i64 type_size_of (gbAllocator allocator, Type *t);
-i64 type_align_of (gbAllocator allocator, Type *t);
-i64 type_offset_of (gbAllocator allocator, Type *t, i32 index);
-gbString type_to_string(Type *type);
+i64 type_size_of (gbAllocator allocator, Type *t);
+i64 type_align_of (gbAllocator allocator, Type *t);
+i64 type_offset_of (gbAllocator allocator, Type *t, i32 index);
+gbString type_to_string (Type *type);
+void generate_map_struct_type(gbAllocator a, Type *type);
@@ -585,6 +586,8 @@ Type *make_type_bit_field(gbAllocator a) {
+
+
////////////////////////////////////////////////////////////////
@@ -1819,6 +1822,8 @@ i64 type_align_of_internal(gbAllocator allocator, Type *t, TypePath *path) {
case Type_Map: {
if (t->Map.count == 0) { // Dynamic
+ // return build_context.word_size;
+ generate_map_struct_type(allocator, t);
return type_align_of_internal(allocator, t->Map.generated_struct_type, path);
}
GB_PANIC("TODO(bill): Fixed map alignment");
@@ -2000,10 +2005,6 @@ i64 type_size_of_internal(gbAllocator allocator, Type *t, TypePath *path) {
return alignment*(count-1) + size;
} break;
- case Type_DynamicArray:
- // data + len + cap + allocator(procedure+data)
- return 3*build_context.word_size + 2*build_context.word_size;
-
case Type_Vector: {
#if 0
i64 count, bit_size, total_size_in_bits, total_size;
@@ -2044,8 +2045,15 @@ i64 type_size_of_internal(gbAllocator allocator, Type *t, TypePath *path) {
case Type_Slice: // ptr + count
return 3 * build_context.word_size;
+ case Type_DynamicArray:
+ // data + len + cap + allocator(procedure+data)
+ return 3*build_context.word_size + 2*build_context.word_size;
+
case Type_Map: {
if (t->Map.count == 0) { // Dynamic
+ // i64 da = 3*build_context.word_size + 2*build_context.word_size;
+ // return 2 * da;
+ generate_map_struct_type(allocator, t);
return type_size_of_internal(allocator, t->Map.generated_struct_type, path);
}
GB_PANIC("TODO(bill): Fixed map size");