diff options
| author | gingerBill <bill@gingerbill.org> | 2019-11-03 00:32:22 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2019-11-03 00:32:22 +0000 |
| commit | ebf7926fa495a7a2d400f44beb4c27888bda33e5 (patch) | |
| tree | 231fe45243a069904c98c03acae05751625d7f71 /src/types.cpp | |
| parent | dfb3101ecf59797884cb959b3bfeda49ccfa3223 (diff) | |
SOA support of Structures and Arrays; Runtime information for SOA structs; fmt printing support for SOA structs
Diffstat (limited to 'src/types.cpp')
| -rw-r--r-- | src/types.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/types.cpp b/src/types.cpp index 6fab6643e..ac78bb943 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -1133,6 +1133,10 @@ bool is_type_union(Type *t) { t = base_type(t); return t->kind == Type_Union; } +bool is_type_soa_struct(Type *t) { + t = base_type(t); + return t->kind == Type_Struct && t->Struct.is_soa; +} bool is_type_raw_union(Type *t) { t = base_type(t); @@ -2194,6 +2198,19 @@ Selection lookup_field_with_selection(Type *type_, String field_name, bool is_ty sel.index.count = prev_count; } } + + bool is_soa = type->Struct.is_soa; + bool is_soa_of_array = is_soa && is_type_array(type->Struct.soa_elem); + + if (is_soa_of_array) { + String mapped_field_name = {}; + if (field_name == "r") mapped_field_name = str_lit("x"); + else if (field_name == "g") mapped_field_name = str_lit("y"); + else if (field_name == "b") mapped_field_name = str_lit("z"); + else if (field_name == "a") mapped_field_name = str_lit("w"); + return lookup_field_with_selection(type, mapped_field_name, is_type, sel, allow_blank_ident); + } + } else if (type->kind == Type_BitField) { for_array(i, type->BitField.fields) { Entity *f = type->BitField.fields[i]; |