aboutsummaryrefslogtreecommitdiff
path: root/src/checker/stmt.cpp
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2016-09-04 22:50:17 +0100
committerGinger Bill <bill@gingerbill.org>2016-09-04 22:50:17 +0100
commitae72b3c5bd80fad917a7e2d78d9945b9f19adb52 (patch)
treeab9709537749da05d33aa0888bc7e1aa3984ed03 /src/checker/stmt.cpp
parentc2e3c3801acd8af32fcf6ea3ad2d3a2ddc94c870 (diff)
Tagged unions memory layout change; begin demo 002
Diffstat (limited to 'src/checker/stmt.cpp')
-rw-r--r--src/checker/stmt.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/checker/stmt.cpp b/src/checker/stmt.cpp
index 78a98a648..75c6ad11d 100644
--- a/src/checker/stmt.cpp
+++ b/src/checker/stmt.cpp
@@ -1238,21 +1238,19 @@ void check_stmt(Checker *c, AstNode *node, u32 flags) {
switch (e->kind) {
case Entity_TypeName: {
Type *t = get_base_type(e->type);
- if (is_type_enum(t)) {
+ if (is_type_struct(t) || is_type_enum(t)) {
for (isize i = 0; i < t->Record.other_field_count; i++) {
Entity *f = t->Record.other_fields[i];
Entity *found = scope_insert_entity(c->context.scope, f);
if (found != NULL) {
- error(&c->error_collector, us->token, "Namespace collision while `using` `%s` of the constant: %.*s", expr_str, LIT(found->token.string));
+ error(&c->error_collector, us->token, "Namespace collision while `using` `%s` of: %.*s", expr_str, LIT(found->token.string));
return;
}
f->using_parent = e;
}
- } else if (is_type_struct(t)) {
- Scope **found = map_get(&c->info.scopes, hash_pointer(t->Record.node));
- GB_ASSERT(found != NULL);
- gb_for_array(i, (*found)->elements.entries) {
- Entity *f = (*found)->elements.entries[i].value;
+ } else if (is_type_union(t)) {
+ for (isize i = 0; i < t->Record.field_count; i++) {
+ Entity *f = t->Record.fields[i];
Entity *found = scope_insert_entity(c->context.scope, f);
if (found != NULL) {
error(&c->error_collector, us->token, "Namespace collision while `using` `%s` of: %.*s", expr_str, LIT(found->token.string));
@@ -1260,11 +1258,8 @@ void check_stmt(Checker *c, AstNode *node, u32 flags) {
}
f->using_parent = e;
}
- } else if (is_type_union(t)) {
- Scope **found = map_get(&c->info.scopes, hash_pointer(t->Record.node));
- GB_ASSERT(found != NULL);
- gb_for_array(i, (*found)->elements.entries) {
- Entity *f = (*found)->elements.entries[i].value;
+ for (isize i = 0; i < t->Record.other_field_count; i++) {
+ Entity *f = t->Record.other_fields[i];
Entity *found = scope_insert_entity(c->context.scope, f);
if (found != NULL) {
error(&c->error_collector, us->token, "Namespace collision while `using` `%s` of: %.*s", expr_str, LIT(found->token.string));