diff options
| author | gingerBill <bill@gingerbill.org> | 2018-11-25 10:35:49 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2018-11-25 10:35:49 +0000 |
| commit | 0a4b88f9a682b08a11f9569c88549855793f0be8 (patch) | |
| tree | fd0e2c51efd7fa997e193491e14bd4f9d158ec40 /src/types.cpp | |
| parent | 4c2f03b1f26bf9d9ec986bb2284e4daa9b4a95aa (diff) | |
Fix Issue with referencing a polymorphic struct in another package referencing itself #283
Diffstat (limited to 'src/types.cpp')
| -rw-r--r-- | src/types.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/types.cpp b/src/types.cpp index fa0cb88d7..3969d9603 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -215,6 +215,11 @@ String const type_strings[] = { TYPE_KINDS #undef TYPE_KIND +enum TypeFlag : u32 { + TypeFlag_Polymorphic = 1<<1, + TypeFlag_PolySpecialized = 1<<2, +}; + struct Type { TypeKind kind; union { @@ -226,6 +231,7 @@ struct Type { // NOTE(bill): These need to be at the end to not affect the unionized data i64 cached_size; i64 cached_align; + u32 flags; // TypeFlag bool failure; }; @@ -1072,6 +1078,7 @@ bool is_type_indexable(Type *t) { return false; } + bool is_type_polymorphic_record(Type *t) { t = base_type(t); if (t->kind == Type_Struct) { @@ -1082,6 +1089,18 @@ bool is_type_polymorphic_record(Type *t) { return false; } +Scope *polymorphic_record_parent_scope(Type *t) { + t = base_type(t); + if (is_type_polymorphic_record(t)) { + if (t->kind == Type_Struct) { + return t->Struct.scope->parent; + } else if (t->kind == Type_Union) { + return t->Union.scope->parent; + } + } + return nullptr; +} + bool is_type_polymorphic_record_specialized(Type *t) { t = base_type(t); if (t->kind == Type_Struct) { |