Code use API rather than raw CheckerInfo; begin work on generic procedures

This commit is contained in:
Ginger Bill
2017-06-15 18:11:58 +01:00
parent c5ef5279d4
commit 1851674b50
7 changed files with 280 additions and 129 deletions
+4 -7
View File
@@ -530,9 +530,7 @@ bool check_using_stmt_entity(Checker *c, AstNodeUsingStmt *us, AstNode *expr, bo
Type *t = base_type(type_deref(e->type));
if (is_type_struct(t) || is_type_raw_union(t) || is_type_union(t)) {
// TODO(bill): Make it work for unions too
Scope **found_ = map_get(&c->info.scopes, hash_pointer(t->Record.node));
GB_ASSERT(found_ != NULL);
Scope *found = *found_;
Scope *found = scope_of_node(&c->info, t->Record.node);
for_array(i, found->elements.entries) {
Entity *f = found->elements.entries[i].value;
if (f->kind == Entity_Variable) {
@@ -1695,10 +1693,9 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
Type *t = base_type(type_deref(e->type));
if (is_type_struct(t) || is_type_raw_union(t)) {
Scope **found = map_get(&c->info.scopes, hash_pointer(t->Record.node));
GB_ASSERT(found != NULL);
for_array(i, (*found)->elements.entries) {
Entity *f = (*found)->elements.entries[i].value;
Scope *scope = scope_of_node(&c->info, t->Record.node);
for_array(i, scope->elements.entries) {
Entity *f = scope->elements.entries[i].value;
if (f->kind == Entity_Variable) {
Entity *uvar = make_entity_using_variable(c->allocator, e, f->token, f->type);
uvar->Variable.is_immutable = is_immutable;