From b94ab4dc05732856e360b12f41b74fb02a19b075 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 15 Mar 2021 14:05:38 +0000 Subject: Make `check_single_global_entity` use `create_checker_context` --- src/checker.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/checker.cpp') diff --git a/src/checker.cpp b/src/checker.cpp index 19c852621..e7271746f 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -3419,6 +3419,11 @@ void check_collect_entities(CheckerContext *c, Slice const &nodes) { } } +CheckerContext *create_checker_context(Checker *c) { + CheckerContext *ctx = gb_alloc_item(heap_allocator(), CheckerContext); + *ctx = c->init_ctx; + return ctx; +} void check_single_global_entity(Checker *c, Entity *e, DeclInfo *d) { GB_ASSERT(e != nullptr); @@ -3431,17 +3436,17 @@ void check_single_global_entity(Checker *c, Entity *e, DeclInfo *d) { return; } - CheckerContext ctx = c->init_ctx; + CheckerContext *ctx = create_checker_context(c); GB_ASSERT(d->scope->flags&ScopeFlag_File); AstFile *file = d->scope->file; - add_curr_ast_file(&ctx, file); + add_curr_ast_file(ctx, file); AstPackage *pkg = file->pkg; - GB_ASSERT(ctx.pkg != nullptr); + GB_ASSERT(ctx->pkg != nullptr); GB_ASSERT(e->pkg != nullptr); - ctx.decl = d; - ctx.scope = d->scope; + ctx->decl = d; + ctx->scope = d->scope; if (!e->pkg->used) { return; @@ -3460,7 +3465,7 @@ void check_single_global_entity(Checker *c, Entity *e, DeclInfo *d) { } } - check_entity_decl(&ctx, e, d, nullptr); + check_entity_decl(ctx, e, d, nullptr); } void check_all_global_entities(Checker *c) { -- cgit v1.2.3