aboutsummaryrefslogtreecommitdiff
path: root/src/check_type.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2018-01-21 14:30:48 +0000
committergingerBill <bill@gingerbill.org>2018-01-21 14:30:48 +0000
commit88ba6d8015966d1a16806b31382d2663add74efc (patch)
tree438116b9008e8bc0458de8a165773220ef7c7b39 /src/check_type.cpp
parent8b288a207254112a3b42ecbef46cecef9f28e811 (diff)
`enum #export`
Diffstat (limited to 'src/check_type.cpp')
-rw-r--r--src/check_type.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp
index e41670bd3..41c975185 100644
--- a/src/check_type.cpp
+++ b/src/check_type.cpp
@@ -796,6 +796,21 @@ void check_enum_type(Checker *c, Type *enum_type, Type *named_type, AstNode *nod
enum_type->Enum.fields = fields.data;
enum_type->Enum.field_count = cast(i32)fields.count;
+ enum_type->Enum.is_export = et->is_export;
+ if (et->is_export) {
+ Scope *parent = c->context.scope->parent;
+ for_array(i, fields) {
+ Entity *f = fields[i];
+ if (f->kind != Entity_Constant) {
+ continue;
+ }
+ String name = f->token.string;
+ if (is_blank_ident(name)) {
+ continue;
+ }
+ add_entity(c, parent, nullptr, f);
+ }
+ }
enum_type->Enum.count = make_entity_constant(c->allocator, c->context.scope,
make_token_ident(str_lit("count")), t_int, exact_value_i64(fields.count));