From 27d9ad3ddc911751a3557dfc7a538ee730a46183 Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Fri, 10 Feb 2023 09:59:06 +0100 Subject: [PATCH] Fix slice codegen inside calls. Add core_free_compiler --- core_codegen_c_language.cpp | 3 +++ core_compiler.cpp | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/core_codegen_c_language.cpp b/core_codegen_c_language.cpp index 76f7805..4a2d484 100644 --- a/core_codegen_c_language.cpp +++ b/core_codegen_c_language.cpp @@ -304,6 +304,9 @@ gen_try_any_or_slice(Ast_Expr *expr, Ast_Type *decl_type){ } else if(expr->kind == AST_IDENT && is_slice(decl_type)){ Ast_Atom *atom = (Ast_Atom *)expr; + gen("("); + gen_simple_decl(decl_type); + gen(")"); gen("{%d, ", atom->resolved_type->arr.size); gen_expr(expr); gen("}"); diff --git a/core_compiler.cpp b/core_compiler.cpp index e726663..f8aa511 100644 --- a/core_compiler.cpp +++ b/core_compiler.cpp @@ -1,4 +1,13 @@ +//apifn +static void core_free_compiler() { + deallocate(pctx->heap, pctx->type_map.data); + deallocate(pctx->heap, pctx->interns.map.data); + arena_release(pctx->stage_arena); + arena_release(pctx->scratch); + arena_release(pctx->perm); +} + //apifn static void core_init_compiler(Core_Ctx *ctx, Allocator *allocator) { ctx->time.init_context = os_time(); @@ -160,7 +169,8 @@ pctx->op_info_table[19] = {pctx->intern("!"_s), "NOT"_s, TK_Not, 0, 1}; } //apifn -static void core_bootstrap_compiler(Allocator *allocator) { +CORE_Static void +core_bootstrap_compiler(Allocator *allocator) { Core_Ctx *ctx = allocate_struct(allocator, Core_Ctx); core_init_compiler(ctx, allocator); }