aboutsummaryrefslogtreecommitdiff
path: root/src/docs_writer.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-03-24 11:55:03 +0000
committergingerBill <bill@gingerbill.org>2022-03-24 11:55:03 +0000
commit3f935bea2505b3ee7e169a29b7aed50c0e5614b7 (patch)
tree3d3886ccfe8146a2226703c1d10b7908f3b54e3b /src/docs_writer.cpp
parent3e66eec7354a8248fe8e0edfccbdc9e8b203e88a (diff)
`union #shared_nil`
This adds a feature to `union` which requires all the variants to have a `nil` value and on assign to the union, checks whether that value is `nil` or not. If the value is `nil`, the union will be `nil` (thus sharing the `nil` value)
Diffstat (limited to 'src/docs_writer.cpp')
-rw-r--r--src/docs_writer.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/docs_writer.cpp b/src/docs_writer.cpp
index 2c5186c39..0ad10ac49 100644
--- a/src/docs_writer.cpp
+++ b/src/docs_writer.cpp
@@ -619,9 +619,11 @@ OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type) {
case Type_Union:
doc_type.kind = OdinDocType_Union;
if (type->Union.is_polymorphic) { doc_type.flags |= OdinDocTypeFlag_Union_polymorphic; }
- if (type->Union.no_nil) { doc_type.flags |= OdinDocTypeFlag_Union_no_nil; }
- if (type->Union.maybe) { doc_type.flags |= OdinDocTypeFlag_Union_maybe; }
-
+ switch (type->Union.kind) {
+ case UnionType_maybe: doc_type.flags |= OdinDocTypeFlag_Union_maybe; break;
+ case UnionType_no_nil: doc_type.flags |= OdinDocTypeFlag_Union_no_nil; break;
+ case UnionType_shared_nil: doc_type.flags |= OdinDocTypeFlag_Union_shared_nil; break;
+ }
{
auto variants = array_make<OdinDocTypeIndex>(heap_allocator(), type->Union.variants.count);
defer (array_free(&variants));