From b89291957acbefbb0e9db90421411094ebc6aed8 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 19 Feb 2025 16:30:19 -0500 Subject: Restructure compile_file() so it moves a bit more towards less usage of side effects --- structs.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'structs.c') diff --git a/structs.c b/structs.c index 7c652678..f4361148 100644 --- a/structs.c +++ b/structs.c @@ -12,7 +12,7 @@ #include "typecheck.h" #include "stdlib/util.h" -void compile_struct_def(env_t *env, ast_t *ast) +CORD compile_struct_typeinfo(env_t *env, ast_t *ast) { auto def = Match(ast, StructDef); CORD full_name = CORD_cat(namespace_prefix(env, env->namespace), def->name); @@ -41,10 +41,7 @@ void compile_struct_def(env_t *env, ast_t *ast) } typeinfo = CORD_all(typeinfo, "}"); } - typeinfo = CORD_all(typeinfo, "};\n"); - env->code->typeinfos = CORD_all(env->code->typeinfos, typeinfo); - - compile_namespace(env, def->name, def->namespace); + return CORD_all(typeinfo, "};\n"); } CORD compile_struct_header(env_t *env, ast_t *ast) -- cgit v1.2.3